Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2022-11-29 09:49:28
Exec Total Coverage
Lines: 1303 3872 33.7%
Functions: 111 335 33.1%
Branches: 600 2728 22.0%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 11 #include "zc_sys.h"
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte disable_direct_updating;
90 byte use_dwm_flush;
91 byte use_save_indicator;
92 byte midi_patch_fix;
93 bool midi_paused=false;
94 int32_t paused_midi_pos = 0;
95 byte midi_suspended = 0;
96 byte callback_switchin = 0;
97 byte zc_192b163_warp_compatibility;
98 char modulepath[2048];
99 byte epilepsyFlashReduction;
100 signed char pause_in_background_menu_init = 0;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
11 byte pause_in_background = 0;
102 bool is_sys_pal = false;
103 extern PALETTE* hw_palette;
104 extern bool update_hw_pal;
105 extern const char* dmaplist(int32_t index, int32_t* list_size);
106
107
108 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
109 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
110 //extern byte refresh_select_screen;
111 //extern movingblock mblock2; //mblock[4]?
112 //extern int32_t db;
113
114 static const char *ZC_str = "Zelda Classic";
115 extern char save_file_name[1024];
116 #ifdef ALLEGRO_DOS
117 const char *qst_dir_name = "dos_qst_dir";
118 #elif defined(ALLEGRO_WINDOWS)
119 const char *qst_dir_name = "win_qst_dir";
120 static const char *qst_module_name = "current_module";
121 #elif defined(ALLEGRO_LINUX)
122 const char *qst_dir_name = "linux_qst_dir";
123 static const char *qst_module_name = "current_module";
124 #elif defined(__APPLE__)
125 const char *qst_dir_name = "osx_qst_dir";
126 static const char *qst_module_name = "current_module";
127 #endif
128 #ifdef ALLEGRO_LINUX
129 static const char *samplepath = "samplesoundset/patches.dat";
130 #endif
131 char qst_files_path[2048];
132
133 #ifdef _MSC_VER
134 #define getcwd _getcwd
135 #endif
136
137 bool rF11();
138 bool rI();
139 bool rQ();
140 bool zc_key_pressed();
141
142 #ifdef _WIN32
143
144 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
145 extern "C"
146 {
147 typedef HRESULT(WINAPI *t_DwmFlush)();
148 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
149 }
150
151 void do_DwmFlush()
152 {
153 static HMODULE shell = LoadLibrary("dwmapi.dll");
154
155 if(!shell)
156 return;
157
158 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
159 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
160
161 BOOL enabled;
162 isEnabled(&enabled);
163
164 if(isEnabled)
165 flush();
166 }
167
168 #endif // _WIN32
169
170 // Dialogue largening
171 void large_dialog(DIALOG *d)
172 {
173 large_dialog(d, 1.5);
174 }
175
176 void large_dialog(DIALOG *d, float RESIZE_AMT)
177 {
178 if(!d[0].d1)
179 {
180 d[0].d1 = 1;
181 int32_t oldwidth = d[0].w;
182 int32_t oldheight = d[0].h;
183 int32_t oldx = d[0].x;
184 int32_t oldy = d[0].y;
185 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
186 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
187 d[0].w = int32_t(d[0].w*RESIZE_AMT);
188 d[0].h = int32_t(d[0].h*RESIZE_AMT);
189
190 for(int32_t i=1; d[i].proc !=NULL; i++)
191 {
192 // Place elements horizontally
193 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
194 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
195
196 if(d[i].proc != d_stringloader)
197 {
198 if(d[i].proc==d_bitmap_proc)
199 {
200 d[i].w *= 2;
201 }
202 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
203 }
204
205 // Place elements vertically
206 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
207 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
208
209 // Vertically resize elements
210 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
211 {
212 d[i].h = int32_t((double)d[i].h*1.5);
213 }
214 else if(d[i].proc == jwin_droplist_proc)
215 {
216 d[i].y += int32_t((double)d[i].h*0.25);
217 d[i].h = int32_t((double)d[i].h*1.25);
218 }
219 else if(d[i].proc==d_bitmap_proc)
220 {
221 d[i].h *= 2;
222 }
223 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
224
225 // Fix frames
226 if(d[i].proc == jwin_frame_proc)
227 {
228 d[i].x++;
229 d[i].y++;
230 d[i].w-=4;
231 d[i].h-=4;
232 }
233 }
234 }
235
236 for(int32_t i=1; d[i].proc!=NULL; i++)
237 {
238 if(d[i].proc==jwin_slider_proc)
239 continue;
240
241 // Bigger font
242 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
243
244 if(!d[i].dp2 && bigfontproc)
245 {
246 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
247 d[i].dp2 = lfont_l;
248 }
249 else if(!bigfontproc)
250 {
251 // ((ListData *)d[i].dp)->font = &sfont3;
252 ((ListData *)d[i].dp)->font = &lfont_l;
253 }
254
255 // Make checkboxes work
256 if(d[i].proc == jwin_check_proc)
257 d[i].proc = jwin_checkfont_proc;
258 else if(d[i].proc == jwin_radio_proc)
259 d[i].proc = jwin_radiofont_proc;
260 }
261
262 jwin_center_dialog(d);
263 }
264
265
266 /**********************************/
267 /******** System functions ********/
268 /**********************************/
269
270 static char cfg_sect[] = "zeldadx"; //We need to rename this.
271
272 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
273 {
274 return D_O_K;
275 }
276
277 11 void load_game_configs()
278 {
279 //set_config_file("zc.cfg"); //shift back when done
280 //load the module
281 11 strcpy(moduledata.module_name,get_config_string("ZCMODULE",qst_module_name,"classic.zmod"));
282 11 joystick_index = zc_get_config(cfg_sect,"joystick_index",0);
283 11 js_stick_1_x_stick = zc_get_config(cfg_sect,"js_stick_1_x_stick",0);
284 11 js_stick_1_x_axis = zc_get_config(cfg_sect,"js_stick_1_x_axis",0);
285 11 js_stick_1_x_offset = zc_get_config(cfg_sect,"js_stick_1_x_offset",0) ? 128 : 0;
286 11 js_stick_1_y_stick = zc_get_config(cfg_sect,"js_stick_1_y_stick",0);
287 11 js_stick_1_y_axis = zc_get_config(cfg_sect,"js_stick_1_y_axis",1);
288 11 js_stick_1_y_offset = zc_get_config(cfg_sect,"js_stick_1_y_offset",0) ? 128 : 0;
289 11 js_stick_2_x_stick = zc_get_config(cfg_sect,"js_stick_2_x_stick",1);
290 11 js_stick_2_x_axis = zc_get_config(cfg_sect,"js_stick_2_x_axis",0);
291 11 js_stick_2_x_offset = zc_get_config(cfg_sect,"js_stick_2_x_offset",0) ? 128 : 0;
292 11 js_stick_2_y_stick = zc_get_config(cfg_sect,"js_stick_2_y_stick",1);
293 11 js_stick_2_y_axis = zc_get_config(cfg_sect,"js_stick_2_y_axis",1);
294 11 js_stick_2_y_offset = zc_get_config(cfg_sect,"js_stick_2_y_offset",0) ? 128 : 0;
295 11 analog_movement = (zc_get_config(cfg_sect,"analog_movement",1));
296
297 //cheat modifier keya
298 11 cheat_modifier_keys[0] = zc_get_config(cfg_sect,"key_cheatmod_a1",KEY_LSHIFT);
299 11 cheat_modifier_keys[1] = zc_get_config(cfg_sect,"key_cheatmod_a2",0);
300 11 cheat_modifier_keys[2] = zc_get_config(cfg_sect,"key_cheatmod_b1",KEY_RSHIFT);
301 11 cheat_modifier_keys[3] = zc_get_config(cfg_sect,"key_cheatmod_b2",0);
302
303
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
304 joystick_index = 0;
305
306 11 Akey = zc_get_config(cfg_sect,"key_a",KEY_ALT);
307 11 Bkey = zc_get_config(cfg_sect,"key_b",KEY_ZC_LCONTROL);
308 11 Skey = zc_get_config(cfg_sect,"key_s",KEY_ENTER);
309 11 Lkey = zc_get_config(cfg_sect,"key_l",KEY_Z);
310 11 Rkey = zc_get_config(cfg_sect,"key_r",KEY_X);
311 11 Pkey = zc_get_config(cfg_sect,"key_p",KEY_SPACE);
312 11 Exkey1 = zc_get_config(cfg_sect,"key_ex1",KEY_Q);
313 11 Exkey2 = zc_get_config(cfg_sect,"key_ex2",KEY_W);
314 11 Exkey3 = zc_get_config(cfg_sect,"key_ex3",KEY_A);
315 11 Exkey4 = zc_get_config(cfg_sect,"key_ex4",KEY_S);
316
317 11 DUkey = zc_get_config(cfg_sect,"key_up", KEY_UP);
318 11 DDkey = zc_get_config(cfg_sect,"key_down", KEY_DOWN);
319 11 DLkey = zc_get_config(cfg_sect,"key_left", KEY_LEFT);
320 11 DRkey = zc_get_config(cfg_sect,"key_right",KEY_RIGHT);
321
322 11 Abtn = zc_get_config(cfg_sect,"btn_a",2);
323 11 Bbtn = zc_get_config(cfg_sect,"btn_b",1);
324 11 Sbtn = zc_get_config(cfg_sect,"btn_s",10);
325 11 Mbtn = zc_get_config(cfg_sect,"btn_m",9);
326 11 Lbtn = zc_get_config(cfg_sect,"btn_l",5);
327 11 Rbtn = zc_get_config(cfg_sect,"btn_r",6);
328 11 Pbtn = zc_get_config(cfg_sect,"btn_p",12);
329 11 Exbtn1 = zc_get_config(cfg_sect,"btn_ex1",7);
330 11 Exbtn2 = zc_get_config(cfg_sect,"btn_ex2",8);
331 11 Exbtn3 = zc_get_config(cfg_sect,"btn_ex3",4);
332 11 Exbtn4 = zc_get_config(cfg_sect,"btn_ex4",3);
333
334 11 DUbtn = zc_get_config(cfg_sect,"btn_up",13);
335 11 DDbtn = zc_get_config(cfg_sect,"btn_down",14);
336 11 DLbtn = zc_get_config(cfg_sect,"btn_left",15);
337 11 DRbtn = zc_get_config(cfg_sect,"btn_right",16);
338
339 11 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
340
341 11 digi_volume = zc_get_config(cfg_sect,"digi",248);
342 11 midi_volume = zc_get_config(cfg_sect,"midi",255);
343 11 sfx_volume = zc_get_config(cfg_sect,"sfx",248);
344 11 emusic_volume = zc_get_config(cfg_sect,"emusic",248);
345 11 pan_style = zc_get_config(cfg_sect,"pan",1);
346 // 1 <= zcmusic_bufsz <= 128
347 11 zcmusic_bufsz = vbound(zc_get_config(cfg_sect,"zcmusic_bufsz",64),1,128);
348 11 volkeys = zc_get_config(cfg_sect,"volkeys",0)!=0;
349 11 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
350 11 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
351 11 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
352 11 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
353 11 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
354 #ifdef __EMSCRIPTEN__
355 if (em_is_mobile()) NameEntryMode = 2;
356 #endif
357 11 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
358 11 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
359 11 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
360 11 title_version = zc_get_config(cfg_sect,"title",2);
361 11 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
362 11 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
363
364 //default - scale x2, 640 x 480
365 11 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
366 11 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
367 11 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
368 11 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
369 11 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
370
371 11 loadlast = zc_get_config(cfg_sect,"load_last",0);
372
373 11 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
374
375 11 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
376
377 //workaround for the 100% CPU bug. -Gleeok
378 #ifdef ALLEGRO_MACOSX //IIRC rest(0) was a mac issue fix.
379 11 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",0);
380 #else
381 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",1);
382 #endif
383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 frame_rest_suggest = zc_min(2, frame_rest_suggest);
384
385 11 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
386
387 #ifdef _WIN32
388 use_debug_console = (byte) zc_get_config(cfg_sect,"debug_console",0);
389 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
390 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
391 console_on_top = (byte) zc_get_config("CONSOLE","console_on_top",0);
392 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
393 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
394
395 // This seems to fix some problems on Windows 7
396 disable_direct_updating = (byte) zc_get_config("graphics","disable_direct_updating",1);
397
398 // This one's for Aero
399 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
400
401 // And this one fixes patches unloading on some MIDI setups
402 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
403 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
404 #else //UNIX
405 11 use_debug_console = false;//(byte) zc_get_config(cfg_sect,"debug_console",0);
406 11 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
407 11 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
408 11 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
409 #endif
410
411 11 char const* default_path = "";
412 11 strcpy(qstdir,get_config_string(cfg_sect,qst_dir_name,default_path));
413
414
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(strlen(qstdir)==0)
415 {
416 1 getcwd(qstdir,2048);
417 1 fix_filename_case(qstdir);
418 1 fix_filename_slashes(qstdir);
419 1 put_backslash(qstdir);
420 1 }
421 else
422 {
423 10 chop_path(qstdir);
424 }
425
426 11 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
427 11 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
428 11 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
429 11 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
430 11 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
431 11 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
432 11 gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
433 11 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
434 11 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
435 11 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
436 11 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
437 11 }
438
439 11 void save_game_configs()
440 {
441 11 packfile_password("");
442
443 11 set_config_string("ZCMODULE",qst_module_name,moduledata.module_name);
444
445 11 set_config_int(cfg_sect,"joystick_index",joystick_index);
446 11 set_config_int(cfg_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
447 11 set_config_int(cfg_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
448 11 set_config_int(cfg_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
449 11 set_config_int(cfg_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
450 11 set_config_int(cfg_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
451 11 set_config_int(cfg_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
452 11 set_config_int(cfg_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
453 11 set_config_int(cfg_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
454 11 set_config_int(cfg_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
455 11 set_config_int(cfg_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
456 11 set_config_int(cfg_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
457 11 set_config_int(cfg_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
458 11 set_config_int(cfg_sect,"analog_movement",analog_movement);
459
460 //cheat modifier keya
461
462 11 set_config_int(cfg_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
463 11 set_config_int(cfg_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
464 11 set_config_int(cfg_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
465 11 set_config_int(cfg_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
466
467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!replay_is_replaying())
468 {
469 11 set_config_int(cfg_sect,"key_a",Akey);
470 11 set_config_int(cfg_sect,"key_b",Bkey);
471 11 set_config_int(cfg_sect,"key_s",Skey);
472 11 set_config_int(cfg_sect,"key_l",Lkey);
473 11 set_config_int(cfg_sect,"key_r",Rkey);
474 11 set_config_int(cfg_sect,"key_p",Pkey);
475 11 set_config_int(cfg_sect,"key_ex1",Exkey1);
476 11 set_config_int(cfg_sect,"key_ex2",Exkey2);
477 11 set_config_int(cfg_sect,"key_ex3",Exkey3);
478 11 set_config_int(cfg_sect,"key_ex4",Exkey4);
479 11 set_config_int(cfg_sect,"key_up", DUkey);
480 11 set_config_int(cfg_sect,"key_down", DDkey);
481 11 set_config_int(cfg_sect,"key_left", DLkey);
482 11 set_config_int(cfg_sect,"key_right",DRkey);
483 11 }
484
485 11 set_config_int(cfg_sect,"btn_a",Abtn);
486 11 set_config_int(cfg_sect,"btn_b",Bbtn);
487 11 set_config_int(cfg_sect,"btn_s",Sbtn);
488 11 set_config_int(cfg_sect,"btn_m",Mbtn);
489 11 set_config_int(cfg_sect,"btn_l",Lbtn);
490 11 set_config_int(cfg_sect,"btn_r",Rbtn);
491 11 set_config_int(cfg_sect,"btn_p",Pbtn);
492 11 set_config_int(cfg_sect,"btn_ex1",Exbtn1);
493 11 set_config_int(cfg_sect,"btn_ex2",Exbtn2);
494 11 set_config_int(cfg_sect,"btn_ex3",Exbtn3);
495 11 set_config_int(cfg_sect,"btn_ex4",Exbtn4);
496
497 11 set_config_int(cfg_sect,"btn_up",DUbtn);
498 11 set_config_int(cfg_sect,"btn_down",DDbtn);
499 11 set_config_int(cfg_sect,"btn_left",DLbtn);
500 11 set_config_int(cfg_sect,"btn_right",DRbtn);
501
502 11 set_config_int(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
503
504 11 set_config_int(cfg_sect,"digi",digi_volume);
505 11 set_config_int(cfg_sect,"midi",midi_volume);
506 11 set_config_int(cfg_sect,"sfx",sfx_volume);
507 11 set_config_int(cfg_sect,"emusic",emusic_volume);
508 11 set_config_int(cfg_sect,"pan",pan_style);
509 11 set_config_int(cfg_sect,"zcmusic_bufsz",zcmusic_bufsz);
510 11 set_config_int(cfg_sect,"volkeys",(int32_t)volkeys);
511 11 set_config_int(cfg_sect,"vsync",zc_vsync);
512 11 set_config_int(cfg_sect,"throttlefps", (int32_t)Throttlefps);
513 11 set_config_int(cfg_sect,"translayers",(int32_t)TransLayers);
514 11 set_config_int(cfg_sect,"snapshot_format",SnapshotFormat);
515 11 set_config_int(cfg_sect,"name_entry_mode",NameEntryMode);
516 11 set_config_int(cfg_sect,"showfps",(int32_t)ShowFPS);
517 11 set_config_int(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
518 11 set_config_int(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
519 11 set_config_int(cfg_sect,"drag_aspect",(int32_t)DragAspect);
520 11 set_config_int(cfg_sect,"fastquit",(int32_t)NESquit);
521 11 set_config_int(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
522 11 set_config_int(cfg_sect,"title",title_version);
523 //set_config_int(cfg_sect,"lister_pattern_matching",abc_patternmatch); //Enable once there is a GUI way to toggle this.
524
525
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
526 {
527 double monitor_scale = zc_get_monitor_scale();
528 window_width = al_get_display_width(all_get_display()) / monitor_scale;
529 window_height = al_get_display_height(all_get_display()) / monitor_scale;
530 }
531
532
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
533 {
534 int o_window_x, o_window_y;
535 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
536 set_config_int(cfg_sect,"window_x",o_window_x);
537 set_config_int(cfg_sect,"window_y",o_window_y);
538 }
539
540
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 if (window_width > 0 && window_height > 0)
541 {
542 11 set_config_int(cfg_sect,"window_width",window_width);
543 11 set_config_int(cfg_sect,"window_height",window_height);
544 11 }
545
546 11 set_config_int(cfg_sect,"load_last",loadlast);
547 11 chop_path(qstdir);
548 11 set_config_string(cfg_sect,qst_dir_name,qstdir);
549 11 set_config_string("SAVEFILE","save_filename",save_file_name);
550 11 set_config_int(cfg_sect,"ss_enable",ss_enable);
551 11 set_config_int(cfg_sect,"ss_after",ss_after);
552 11 set_config_int(cfg_sect,"ss_speed",ss_speed);
553 11 set_config_int(cfg_sect,"ss_density",ss_density);
554 11 set_config_int(cfg_sect,"heart_beep",heart_beep);
555 11 set_config_int(cfg_sect,"gui_colorset",gui_colorset);
556 11 set_config_int(cfg_sect,"use_sfx_dat",sfxdat);
557 11 set_config_int(cfg_sect,"fullscreen",fullscreen);
558 11 set_config_int(cfg_sect,"color_depth",zc_color_depth);
559 11 set_config_int(cfg_sect,"frame_rest_suggest",frame_rest_suggest);
560 11 set_config_int(cfg_sect,"force_exit",forceExit);
561
562 #ifdef _WIN32
563 set_config_int(cfg_sect,"debug_console",use_debug_console);
564 set_config_int("CONSOLE","print_ZASM",zasm_debugger);
565 set_config_int("CONSOLE","ZScript_Debugger",zscript_debugger);
566 set_config_int("CONSOLE","console_on_top",console_on_top);
567 //set_config_int(cfg_sect,"use_win7_key_fix",use_win7_keyboard_fix);
568 set_config_int(cfg_sect,"zc_win_proc_fix",use_win32_proc);
569 set_config_int("graphics","disable_direct_updating",disable_direct_updating);
570 set_config_int("zeldadx","use_dwm_flush",use_dwm_flush);
571 set_config_int("zeldadx","midi_patch_fix",midi_patch_fix);
572 set_config_int("CONSOLE","monochrome_debuggers",monochrome_console);
573 set_config_int("zeldadx","debug_console",zconsole);
574 #endif
575
576 #ifdef ALLEGRO_LINUX
577 set_config_string("sound","patches",samplepath); // set to sample sound path set for DIGMIDI driver in Linux ~ Takuya
578 #endif
579
580 11 set_config_int(cfg_sect,"save_indicator",use_save_indicator);
581 11 set_config_int(cfg_sect,"zc_192b163_warp_compatibility",zc_192b163_warp_compatibility);
582
583 11 flush_config_file();
584 #ifdef __EMSCRIPTEN__
585 em_sync_fs();
586 #endif
587 11 }
588
589 //----------------------------------------------------------------
590
591 // Timers
592
593 1301 void fps_callback()
594 {
595 1301 lastfps=framecnt;
596 1301 dword tempsecs = fps_secs;
597 1301 ++tempsecs;
598 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
599 1301 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
600 1301 ++fps_secs;
601 1301 framecnt=0;
602 1301 }
603
604 END_OF_FUNCTION(fps_callback)
605
606 11 int32_t Z_init_timers()
607 {
608 static bool didit = false;
609 const static char *err_str = "Couldn't allocate timer";
610 11 err_str = err_str; //Unused variable warning
611
612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(didit)
613 return 1;
614
615 11 didit = true;
616
617 LOCK_VARIABLE(lastfps);
618 LOCK_VARIABLE(framecnt);
619 LOCK_FUNCTION(fps_callback);
620
621
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
622 return 0;
623
624 11 return 1;
625 11 }
626
627 void Z_remove_timers()
628 {
629 remove_int(fps_callback);
630 }
631
632 //----------------------------------------------------------------
633
634 void go()
635 {
636 scare_mouse();
637 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
638 unscare_mouse();
639 }
640
641 void comeback()
642 {
643 scare_mouse();
644 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
645 unscare_mouse();
646 }
647
648 void dump_pal(BITMAP *dest)
649 {
650 for(int32_t i=0; i<256; i++)
651 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
652 }
653
654 //----------------------------------------------------------------
655
656 //Handles converting the mouse sprite from the .dat file
657 11 void load_mouse()
658 {
659 11 system_pal();
660 11 scare_mouse();
661 11 set_mouse_sprite(NULL);
662
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 int32_t sz = vbound(int32_t(16*(is_large ? get_config_float("zeldadx","cursor_scale_large",1.5) : get_config_float("zeldadx","cursor_scale_small",1))),16,80);
663
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t j = 0; j < 4; ++j)
664 {
665 44 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
666 44 BITMAP* subbmp = create_bitmap_ex(8,16,16);
667
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(zcmouse[j])
668 destroy_bitmap(zcmouse[j]);
669 44 zcmouse[j] = create_bitmap_ex(8,sz,sz);
670 44 clear_bitmap(zcmouse[j]);
671 44 clear_bitmap(tmpbmp);
672 44 clear_bitmap(subbmp);
673 44 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
674
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 44 times.
748 for(int32_t x = 0; x < 16; ++x)
675 {
676
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 704 times.
11968 for(int32_t y = 0; y < 16; ++y)
677 {
678 11264 int32_t color = getpixel(tmpbmp, x, y);
679
5/5
✓ Branch 0 taken 10362 times.
✓ Branch 1 taken 209 times.
✓ Branch 2 taken 242 times.
✓ Branch 3 taken 253 times.
✓ Branch 4 taken 198 times.
11264 switch(color)
680 {
681 case dvc(1):
682 209 color = jwin_pal[jcCURSORMISC];
683 209 break;
684 case dvc(2):
685 242 color = jwin_pal[jcCURSOROUTLINE];
686 242 break;
687 case dvc(3):
688 253 color = jwin_pal[jcCURSORLIGHT];
689 253 break;
690 case dvc(5):
691 198 color = jwin_pal[jcCURSORDARK];
692 198 break;
693 }
694 11264 putpixel(subbmp, x, y, color);
695 11264 }
696 704 }
697
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(sz!=16)
698 44 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
699 else
700 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
701 44 destroy_bitmap(tmpbmp);
702 44 destroy_bitmap(subbmp);
703 44 }
704 11 set_mouse_sprite(zcmouse[0]);
705
706 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
707 11 set_palette(*hw_palette);
708 11 show_mouse(screen);
709 11 show_mouse(NULL);
710
711 11 unscare_mouse();
712 11 game_pal();
713 11 }
714
715 // sets the video mode and initializes the palette and mouse sprite
716 11 bool game_vid_mode(int32_t mode,int32_t wait)
717 {
718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
719 {
720 return false;
721 }
722
723 11 scrx = (resx-320)>>1;
724 11 scry = (resy-240)>>1;
725
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t q = 0; q < 4; ++q)
726 44 zcmouse[q] = NULL;
727 11 load_mouse();
728 11 set_mouse_sprite(zcmouse[0]);
729
730
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 11 times.
187 for(int32_t i=240; i<256; i++)
731 176 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
732
733 11 set_palette(RAMpal);
734 11 clear_to_color(screen,BLACK);
735
736 11 rest(wait);
737 11 return true;
738 11 }
739
740 void null_quest()
741 {
742 char qstdat_string[2048];
743 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
744 strcat(qstdat_string,"#NESQST_NEW_QST");
745
746 #ifdef __EMSCRIPTEN__
747 // The quest template data file is not included because it's really big and isn't really needed
748 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
749 // which is much smaller.
750 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
751 #endif
752
753 byte skip_flags[4] = { 0 };
754
755 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
756 }
757
758 void init_NES_mode()
759 {
760 /*
761 // qst.dat may not load correctly without this...
762 QHeader.templatepath[0]='\0';
763
764 if(!init_colordata(true, &QHeader, &QMisc))
765 {
766 return;
767 }
768
769 loadfullpal();
770 init_tiles(false, &QHeader);
771 */
772 null_quest();
773 }
774
775 //----------------------------------------------------------------
776
777 qword trianglelines[16]=
778 {
779 0x0000000000000000ULL,
780 0xFD00000000000000ULL,
781 0xFDFD000000000000ULL,
782 0xFDFDFD0000000000ULL,
783 0xFDFDFDFD00000000ULL,
784 0xFDFDFDFDFD000000ULL,
785 0xFDFDFDFDFDFD0000ULL,
786 0xFDFDFDFDFDFDFD00ULL,
787 0xFDFDFDFDFDFDFDFDULL,
788 0x00FDFDFDFDFDFDFDULL,
789 0x0000FDFDFDFDFDFDULL,
790 0x000000FDFDFDFDFDULL,
791 0x00000000FDFDFDFDULL,
792 0x0000000000FDFDFDULL,
793 0x000000000000FDFDULL,
794 0x00000000000000FDULL,
795 };
796
797 word screen_triangles[28][32];
798 /*
799 qword triangles[4][16]= //[direction][value]
800 {
801 {
802 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
803 },
804 {
805 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
806 },
807 {
808 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
809 },
810 {
811 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
812 }
813 };
814 */
815
816
817 /*
818 byte triangles[4][16][8]= //[direction][value][line]
819 {
820 {
821 {
822 0, 0, 0, 0, 0, 0, 0, 0
823 },
824 {
825 1, 0, 0, 0, 0, 0, 0, 0
826 },
827 {
828 2, 1, 0, 0, 0, 0, 0, 0
829 },
830 {
831 3, 2, 1, 0, 0, 0, 0, 0
832 },
833 {
834 4, 3, 2, 1, 0, 0, 0, 0
835 },
836 {
837 5, 4, 3, 2, 1, 0, 0, 0
838 },
839 {
840 6, 5, 4, 3, 2, 1, 0, 0
841 },
842 {
843 7, 6, 5, 4, 3, 2, 1, 0
844 },
845 {
846 8, 7, 6, 5, 4, 3, 2, 1
847 },
848 {
849 8, 8, 7, 6, 5, 4, 3, 2
850 },
851 {
852 8, 8, 8, 7, 6, 5, 4, 3
853 },
854 {
855 8, 8, 8, 8, 7, 6, 5, 4
856 },
857 {
858 8, 8, 8, 8, 8, 7, 6, 5
859 },
860 {
861 8, 8, 8, 8, 8, 8, 7, 6
862 },
863 {
864 8, 8, 8, 8, 8, 8, 8, 7
865 },
866 {
867 8, 8, 8, 8, 8, 8, 8, 8
868 }
869 },
870 {
871 {
872 0, 0, 0, 0, 0, 0, 0, 0
873 },
874 {
875 15, 0, 0, 0, 0, 0, 0, 0
876 },
877 {
878 14, 15, 0, 0, 0, 0, 0, 0
879 },
880 {
881 13, 14, 15, 0, 0, 0, 0, 0
882 },
883 {
884 12, 13, 14, 15, 0, 0, 0, 0
885 },
886 {
887 11, 12, 13, 14, 15, 0, 0, 0
888 },
889 {
890 10, 11, 12, 13, 14, 15, 0, 0
891 },
892 {
893 9, 10, 11, 12, 13, 14, 15, 0
894 },
895 {
896 8, 9, 10, 11, 12, 13, 14, 15
897 },
898 {
899 8, 8, 9, 10, 11, 12, 13, 14
900 },
901 {
902 8, 8, 8, 9, 10, 11, 12, 13
903 },
904 {
905 8, 8, 8, 8, 9, 10, 11, 12
906 },
907 {
908 8, 8, 8, 8, 8, 9, 10, 11
909 },
910 {
911 8, 8, 8, 8, 8, 8, 9, 10
912 },
913 {
914 8, 8, 8, 8, 8, 8, 8, 9
915 },
916 {
917 8, 8, 8, 8, 8, 8, 8, 8
918 }
919 },
920 {
921 {
922 0, 0, 0, 0, 0, 0, 0, 0
923 },
924 {
925 0, 0, 0, 0, 0, 0, 0, 1
926 },
927 {
928 0, 0, 0, 0, 0, 0, 1, 2
929 },
930 {
931 0, 0, 0, 0, 0, 1, 2, 3
932 },
933 {
934 0, 0, 0, 0, 1, 2, 3, 4
935 },
936 {
937 0, 0, 0, 1, 2, 3, 4, 5
938 },
939 {
940 0, 0, 1, 2, 3, 4, 5, 6
941 },
942 {
943 0, 1, 2, 3, 4, 5, 6, 7
944 },
945 {
946 1, 2, 3, 4, 5, 6, 7, 8
947 },
948 {
949 2, 3, 4, 5, 6, 7, 8, 8
950 },
951 {
952 3, 4, 5, 6, 7, 8, 8, 8
953 },
954 {
955 4, 5, 6, 7, 8, 8, 8, 8
956 },
957 {
958 5, 6, 7, 8, 8, 8, 8, 8
959 },
960 {
961 6, 7, 8, 8, 8, 8, 8, 8
962 },
963 {
964 7, 8, 8, 8, 8, 8, 8, 8
965 },
966 {
967 8, 8, 8, 8, 8, 8, 8, 8
968 }
969 },
970 {
971 {
972 0, 0, 0, 0, 0, 0, 0, 0
973 },
974 {
975 0, 0, 0, 0, 0, 0, 0, 15
976 },
977 {
978 0, 0, 0, 0, 0, 0, 15, 14
979 },
980 {
981 0, 0, 0, 0, 0, 15, 14, 13
982 },
983 {
984 0, 0, 0, 0, 15, 14, 13, 12
985 },
986 {
987 0, 0, 0, 15, 14, 13, 12, 11
988 },
989 {
990 0, 0, 15, 14, 13, 12, 11, 10
991 },
992 {
993 0, 15, 14, 13, 12, 11, 10, 9
994 },
995 {
996 15, 14, 13, 12, 11, 10, 9, 8
997 },
998 {
999 14, 13, 12, 11, 10, 9, 8, 8
1000 },
1001 {
1002 13, 12, 11, 10, 9, 8, 8, 8
1003 },
1004 {
1005 12, 11, 10, 9, 8, 8, 8, 8
1006 },
1007 {
1008 11, 10, 9, 8, 8, 8, 8, 8
1009 },
1010 {
1011 10, 9, 8, 8, 8, 8, 8, 8
1012 },
1013 {
1014 9, 8, 8, 8, 8, 8, 8, 8
1015 },
1016 {
1017 8, 8, 8, 8, 8, 8, 8, 8
1018 }
1019 }
1020 };
1021 */
1022
1023
1024
1025 /*
1026 for (int32_t blockrow=0; blockrow<30; ++i)
1027 {
1028 for (int32_t linerow=0; linerow<8; ++i)
1029 {
1030 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1031 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1032 {
1033 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1034 ++triangleline;
1035 }
1036 }
1037 }
1038 */
1039
1040 // the ULL suffixes are to prevent this warning:
1041 // warning: integer constant is too large for "int32_t" type
1042
1043 qword triangles[4][16][8]= //[direction][value][line]
1044 {
1045 {
1046 {
1047 0x0000000000000000ULL,
1048 0x0000000000000000ULL,
1049 0x0000000000000000ULL,
1050 0x0000000000000000ULL,
1051 0x0000000000000000ULL,
1052 0x0000000000000000ULL,
1053 0x0000000000000000ULL,
1054 0x0000000000000000ULL
1055 },
1056 {
1057 0xFD00000000000000ULL,
1058 0x0000000000000000ULL,
1059 0x0000000000000000ULL,
1060 0x0000000000000000ULL,
1061 0x0000000000000000ULL,
1062 0x0000000000000000ULL,
1063 0x0000000000000000ULL,
1064 0x0000000000000000ULL
1065 },
1066 {
1067 0xFDFD000000000000ULL,
1068 0xFD00000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL
1075 },
1076 {
1077 0xFDFDFD0000000000ULL,
1078 0xFDFD000000000000ULL,
1079 0xFD00000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL
1085 },
1086 {
1087 0xFDFDFDFD00000000ULL,
1088 0xFDFDFD0000000000ULL,
1089 0xFDFD000000000000ULL,
1090 0xFD00000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL
1095 },
1096 {
1097 0xFDFDFDFDFD000000ULL,
1098 0xFDFDFDFD00000000ULL,
1099 0xFDFDFD0000000000ULL,
1100 0xFDFD000000000000ULL,
1101 0xFD00000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL
1105 },
1106 {
1107 0xFDFDFDFDFDFD0000ULL,
1108 0xFDFDFDFDFD000000ULL,
1109 0xFDFDFDFD00000000ULL,
1110 0xFDFDFD0000000000ULL,
1111 0xFDFD000000000000ULL,
1112 0xFD00000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL
1115 },
1116 {
1117 0xFDFDFDFDFDFDFD00ULL,
1118 0xFDFDFDFDFDFD0000ULL,
1119 0xFDFDFDFDFD000000ULL,
1120 0xFDFDFDFD00000000ULL,
1121 0xFDFDFD0000000000ULL,
1122 0xFDFD000000000000ULL,
1123 0xFD00000000000000ULL,
1124 0x0000000000000000ULL
1125 },
1126 {
1127 0xFDFDFDFDFDFDFDFDULL,
1128 0xFDFDFDFDFDFDFD00ULL,
1129 0xFDFDFDFDFDFD0000ULL,
1130 0xFDFDFDFDFD000000ULL,
1131 0xFDFDFDFD00000000ULL,
1132 0xFDFDFD0000000000ULL,
1133 0xFDFD000000000000ULL,
1134 0xFD00000000000000ULL
1135 },
1136 {
1137 0xFDFDFDFDFDFDFDFDULL,
1138 0xFDFDFDFDFDFDFDFDULL,
1139 0xFDFDFDFDFDFDFD00ULL,
1140 0xFDFDFDFDFDFD0000ULL,
1141 0xFDFDFDFDFD000000ULL,
1142 0xFDFDFDFD00000000ULL,
1143 0xFDFDFD0000000000ULL,
1144 0xFDFD000000000000ULL
1145 },
1146 {
1147 0xFDFDFDFDFDFDFDFDULL,
1148 0xFDFDFDFDFDFDFDFDULL,
1149 0xFDFDFDFDFDFDFDFDULL,
1150 0xFDFDFDFDFDFDFD00ULL,
1151 0xFDFDFDFDFDFD0000ULL,
1152 0xFDFDFDFDFD000000ULL,
1153 0xFDFDFDFD00000000ULL,
1154 0xFDFDFD0000000000ULL
1155 },
1156 {
1157 0xFDFDFDFDFDFDFDFDULL,
1158 0xFDFDFDFDFDFDFDFDULL,
1159 0xFDFDFDFDFDFDFDFDULL,
1160 0xFDFDFDFDFDFDFDFDULL,
1161 0xFDFDFDFDFDFDFD00ULL,
1162 0xFDFDFDFDFDFD0000ULL,
1163 0xFDFDFDFDFD000000ULL,
1164 0xFDFDFDFD00000000ULL
1165 },
1166 {
1167 0xFDFDFDFDFDFDFDFDULL,
1168 0xFDFDFDFDFDFDFDFDULL,
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0xFDFDFDFDFDFDFDFDULL,
1171 0xFDFDFDFDFDFDFDFDULL,
1172 0xFDFDFDFDFDFDFD00ULL,
1173 0xFDFDFDFDFDFD0000ULL,
1174 0xFDFDFDFDFD000000ULL
1175 },
1176 {
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFDFDULL,
1183 0xFDFDFDFDFDFDFD00ULL,
1184 0xFDFDFDFDFDFD0000ULL
1185 },
1186 {
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFDFDULL,
1194 0xFDFDFDFDFDFDFD00ULL
1195 },
1196 {
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFDFDULL
1205 }
1206 },
1207 {
1208 {
1209 0x0000000000000000ULL,
1210 0x0000000000000000ULL,
1211 0x0000000000000000ULL,
1212 0x0000000000000000ULL,
1213 0x0000000000000000ULL,
1214 0x0000000000000000ULL,
1215 0x0000000000000000ULL,
1216 0x0000000000000000ULL
1217 },
1218 {
1219 0x00000000000000FDULL,
1220 0x0000000000000000ULL,
1221 0x0000000000000000ULL,
1222 0x0000000000000000ULL,
1223 0x0000000000000000ULL,
1224 0x0000000000000000ULL,
1225 0x0000000000000000ULL,
1226 0x0000000000000000ULL
1227 },
1228 {
1229 0x000000000000FDFDULL,
1230 0x00000000000000FDULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL
1237 },
1238 {
1239 0x0000000000FDFDFDULL,
1240 0x000000000000FDFDULL,
1241 0x00000000000000FDULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL
1247 },
1248 {
1249 0x00000000FDFDFDFDULL,
1250 0x0000000000FDFDFDULL,
1251 0x000000000000FDFDULL,
1252 0x00000000000000FDULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL
1257 },
1258 {
1259 0x000000FDFDFDFDFDULL,
1260 0x00000000FDFDFDFDULL,
1261 0x0000000000FDFDFDULL,
1262 0x000000000000FDFDULL,
1263 0x00000000000000FDULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL
1267 },
1268 {
1269 0x0000FDFDFDFDFDFDULL,
1270 0x000000FDFDFDFDFDULL,
1271 0x00000000FDFDFDFDULL,
1272 0x0000000000FDFDFDULL,
1273 0x000000000000FDFDULL,
1274 0x00000000000000FDULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL
1277 },
1278 {
1279 0x00FDFDFDFDFDFDFDULL,
1280 0x0000FDFDFDFDFDFDULL,
1281 0x000000FDFDFDFDFDULL,
1282 0x00000000FDFDFDFDULL,
1283 0x0000000000FDFDFDULL,
1284 0x000000000000FDFDULL,
1285 0x00000000000000FDULL,
1286 0x0000000000000000ULL
1287 },
1288 {
1289 0xFDFDFDFDFDFDFDFDULL,
1290 0x00FDFDFDFDFDFDFDULL,
1291 0x0000FDFDFDFDFDFDULL,
1292 0x000000FDFDFDFDFDULL,
1293 0x00000000FDFDFDFDULL,
1294 0x0000000000FDFDFDULL,
1295 0x000000000000FDFDULL,
1296 0x00000000000000FDULL
1297 },
1298 {
1299 0xFDFDFDFDFDFDFDFDULL,
1300 0xFDFDFDFDFDFDFDFDULL,
1301 0x00FDFDFDFDFDFDFDULL,
1302 0x0000FDFDFDFDFDFDULL,
1303 0x000000FDFDFDFDFDULL,
1304 0x00000000FDFDFDFDULL,
1305 0x0000000000FDFDFDULL,
1306 0x000000000000FDFDULL
1307 },
1308 {
1309 0xFDFDFDFDFDFDFDFDULL,
1310 0xFDFDFDFDFDFDFDFDULL,
1311 0xFDFDFDFDFDFDFDFDULL,
1312 0x00FDFDFDFDFDFDFDULL,
1313 0x0000FDFDFDFDFDFDULL,
1314 0x000000FDFDFDFDFDULL,
1315 0x00000000FDFDFDFDULL,
1316 0x0000000000FDFDFDULL
1317 },
1318 {
1319 0xFDFDFDFDFDFDFDFDULL,
1320 0xFDFDFDFDFDFDFDFDULL,
1321 0xFDFDFDFDFDFDFDFDULL,
1322 0xFDFDFDFDFDFDFDFDULL,
1323 0x00FDFDFDFDFDFDFDULL,
1324 0x0000FDFDFDFDFDFDULL,
1325 0x000000FDFDFDFDFDULL,
1326 0x00000000FDFDFDFDULL
1327 },
1328 {
1329 0xFDFDFDFDFDFDFDFDULL,
1330 0xFDFDFDFDFDFDFDFDULL,
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0xFDFDFDFDFDFDFDFDULL,
1334 0x00FDFDFDFDFDFDFDULL,
1335 0x0000FDFDFDFDFDFDULL,
1336 0x000000FDFDFDFDFDULL
1337 },
1338 {
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0xFDFDFDFDFDFDFDFDULL,
1345 0x00FDFDFDFDFDFDFDULL,
1346 0x0000FDFDFDFDFDFDULL
1347 },
1348 {
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0xFDFDFDFDFDFDFDFDULL,
1356 0x00FDFDFDFDFDFDFDULL
1357 },
1358 {
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0xFDFDFDFDFDFDFDFDULL
1367 }
1368 },
1369 {
1370 {
1371 0x0000000000000000ULL,
1372 0x0000000000000000ULL,
1373 0x0000000000000000ULL,
1374 0x0000000000000000ULL,
1375 0x0000000000000000ULL,
1376 0x0000000000000000ULL,
1377 0x0000000000000000ULL,
1378 0x0000000000000000ULL
1379 },
1380 {
1381 0x0000000000000000ULL,
1382 0x0000000000000000ULL,
1383 0x0000000000000000ULL,
1384 0x0000000000000000ULL,
1385 0x0000000000000000ULL,
1386 0x0000000000000000ULL,
1387 0x0000000000000000ULL,
1388 0xFD00000000000000ULL
1389 },
1390 {
1391 0x0000000000000000ULL,
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0xFD00000000000000ULL,
1398 0xFDFD000000000000ULL
1399 },
1400 {
1401 0x0000000000000000ULL,
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0xFD00000000000000ULL,
1407 0xFDFD000000000000ULL,
1408 0xFDFDFD0000000000ULL
1409 },
1410 {
1411 0x0000000000000000ULL,
1412 0x0000000000000000ULL,
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0xFD00000000000000ULL,
1416 0xFDFD000000000000ULL,
1417 0xFDFDFD0000000000ULL,
1418 0xFDFDFDFD00000000ULL
1419 },
1420 {
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0xFD00000000000000ULL,
1425 0xFDFD000000000000ULL,
1426 0xFDFDFD0000000000ULL,
1427 0xFDFDFDFD00000000ULL,
1428 0xFDFDFDFDFD000000ULL
1429 },
1430 {
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0xFD00000000000000ULL,
1434 0xFDFD000000000000ULL,
1435 0xFDFDFD0000000000ULL,
1436 0xFDFDFDFD00000000ULL,
1437 0xFDFDFDFDFD000000ULL,
1438 0xFDFDFDFDFDFD0000ULL
1439 },
1440 {
1441 0x0000000000000000ULL,
1442 0xFD00000000000000ULL,
1443 0xFDFD000000000000ULL,
1444 0xFDFDFD0000000000ULL,
1445 0xFDFDFDFD00000000ULL,
1446 0xFDFDFDFDFD000000ULL,
1447 0xFDFDFDFDFDFD0000ULL,
1448 0xFDFDFDFDFDFDFD00ULL
1449 },
1450 {
1451 0xFD00000000000000ULL,
1452 0xFDFD000000000000ULL,
1453 0xFDFDFD0000000000ULL,
1454 0xFDFDFDFD00000000ULL,
1455 0xFDFDFDFDFD000000ULL,
1456 0xFDFDFDFDFDFD0000ULL,
1457 0xFDFDFDFDFDFDFD00ULL,
1458 0xFDFDFDFDFDFDFDFDULL
1459 },
1460 {
1461 0xFDFD000000000000ULL,
1462 0xFDFDFD0000000000ULL,
1463 0xFDFDFDFD00000000ULL,
1464 0xFDFDFDFDFD000000ULL,
1465 0xFDFDFDFDFDFD0000ULL,
1466 0xFDFDFDFDFDFDFD00ULL,
1467 0xFDFDFDFDFDFDFDFDULL,
1468 0xFDFDFDFDFDFDFDFDULL
1469 },
1470 {
1471 0xFDFDFD0000000000ULL,
1472 0xFDFDFDFD00000000ULL,
1473 0xFDFDFDFDFD000000ULL,
1474 0xFDFDFDFDFDFD0000ULL,
1475 0xFDFDFDFDFDFDFD00ULL,
1476 0xFDFDFDFDFDFDFDFDULL,
1477 0xFDFDFDFDFDFDFDFDULL,
1478 0xFDFDFDFDFDFDFDFDULL
1479 },
1480 {
1481 0xFDFDFDFD00000000ULL,
1482 0xFDFDFDFDFD000000ULL,
1483 0xFDFDFDFDFDFD0000ULL,
1484 0xFDFDFDFDFDFDFD00ULL,
1485 0xFDFDFDFDFDFDFDFDULL,
1486 0xFDFDFDFDFDFDFDFDULL,
1487 0xFDFDFDFDFDFDFDFDULL,
1488 0xFDFDFDFDFDFDFDFDULL
1489 },
1490 {
1491 0xFDFDFDFDFD000000ULL,
1492 0xFDFDFDFDFDFD0000ULL,
1493 0xFDFDFDFDFDFDFD00ULL,
1494 0xFDFDFDFDFDFDFDFDULL,
1495 0xFDFDFDFDFDFDFDFDULL,
1496 0xFDFDFDFDFDFDFDFDULL,
1497 0xFDFDFDFDFDFDFDFDULL,
1498 0xFDFDFDFDFDFDFDFDULL
1499 },
1500 {
1501 0xFDFDFDFDFDFD0000ULL,
1502 0xFDFDFDFDFDFDFD00ULL,
1503 0xFDFDFDFDFDFDFDFDULL,
1504 0xFDFDFDFDFDFDFDFDULL,
1505 0xFDFDFDFDFDFDFDFDULL,
1506 0xFDFDFDFDFDFDFDFDULL,
1507 0xFDFDFDFDFDFDFDFDULL,
1508 0xFDFDFDFDFDFDFDFDULL
1509 },
1510 {
1511 0xFDFDFDFDFDFDFD00ULL,
1512 0xFDFDFDFDFDFDFDFDULL,
1513 0xFDFDFDFDFDFDFDFDULL,
1514 0xFDFDFDFDFDFDFDFDULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL
1519 },
1520 {
1521 0xFDFDFDFDFDFDFDFDULL,
1522 0xFDFDFDFDFDFDFDFDULL,
1523 0xFDFDFDFDFDFDFDFDULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL
1529 }
1530 },
1531 {
1532 {
1533 0x0000000000000000ULL,
1534 0x0000000000000000ULL,
1535 0x0000000000000000ULL,
1536 0x0000000000000000ULL,
1537 0x0000000000000000ULL,
1538 0x0000000000000000ULL,
1539 0x0000000000000000ULL,
1540 0x0000000000000000ULL
1541 },
1542 {
1543 0x0000000000000000ULL,
1544 0x0000000000000000ULL,
1545 0x0000000000000000ULL,
1546 0x0000000000000000ULL,
1547 0x0000000000000000ULL,
1548 0x0000000000000000ULL,
1549 0x0000000000000000ULL,
1550 0x00000000000000FDULL
1551 },
1552 {
1553 0x0000000000000000ULL,
1554 0x0000000000000000ULL,
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x00000000000000FDULL,
1560 0x000000000000FDFDULL
1561 },
1562 {
1563 0x0000000000000000ULL,
1564 0x0000000000000000ULL,
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x00000000000000FDULL,
1569 0x000000000000FDFDULL,
1570 0x0000000000FDFDFDULL
1571 },
1572 {
1573 0x0000000000000000ULL,
1574 0x0000000000000000ULL,
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x00000000000000FDULL,
1578 0x000000000000FDFDULL,
1579 0x0000000000FDFDFDULL,
1580 0x00000000FDFDFDFDULL
1581 },
1582 {
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x00000000000000FDULL,
1587 0x000000000000FDFDULL,
1588 0x0000000000FDFDFDULL,
1589 0x00000000FDFDFDFDULL,
1590 0x000000FDFDFDFDFDULL
1591 },
1592 {
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x00000000000000FDULL,
1596 0x000000000000FDFDULL,
1597 0x0000000000FDFDFDULL,
1598 0x00000000FDFDFDFDULL,
1599 0x000000FDFDFDFDFDULL,
1600 0x0000FDFDFDFDFDFDULL
1601 },
1602 {
1603 0x0000000000000000ULL,
1604 0x00000000000000FDULL,
1605 0x000000000000FDFDULL,
1606 0x0000000000FDFDFDULL,
1607 0x00000000FDFDFDFDULL,
1608 0x000000FDFDFDFDFDULL,
1609 0x0000FDFDFDFDFDFDULL,
1610 0x00FDFDFDFDFDFDFDULL
1611 },
1612 {
1613 0x00000000000000FDULL,
1614 0x000000000000FDFDULL,
1615 0x0000000000FDFDFDULL,
1616 0x00000000FDFDFDFDULL,
1617 0x000000FDFDFDFDFDULL,
1618 0x0000FDFDFDFDFDFDULL,
1619 0x00FDFDFDFDFDFDFDULL,
1620 0xFDFDFDFDFDFDFDFDULL
1621 },
1622 {
1623 0x000000000000FDFDULL,
1624 0x0000000000FDFDFDULL,
1625 0x00000000FDFDFDFDULL,
1626 0x000000FDFDFDFDFDULL,
1627 0x0000FDFDFDFDFDFDULL,
1628 0x00FDFDFDFDFDFDFDULL,
1629 0xFDFDFDFDFDFDFDFDULL,
1630 0xFDFDFDFDFDFDFDFDULL
1631 },
1632 {
1633 0x0000000000FDFDFDULL,
1634 0x00000000FDFDFDFDULL,
1635 0x000000FDFDFDFDFDULL,
1636 0x0000FDFDFDFDFDFDULL,
1637 0x00FDFDFDFDFDFDFDULL,
1638 0xFDFDFDFDFDFDFDFDULL,
1639 0xFDFDFDFDFDFDFDFDULL,
1640 0xFDFDFDFDFDFDFDFDULL
1641 },
1642 {
1643 0x00000000FDFDFDFDULL,
1644 0x000000FDFDFDFDFDULL,
1645 0x0000FDFDFDFDFDFDULL,
1646 0x00FDFDFDFDFDFDFDULL,
1647 0xFDFDFDFDFDFDFDFDULL,
1648 0xFDFDFDFDFDFDFDFDULL,
1649 0xFDFDFDFDFDFDFDFDULL,
1650 0xFDFDFDFDFDFDFDFDULL
1651 },
1652 {
1653 0x000000FDFDFDFDFDULL,
1654 0x0000FDFDFDFDFDFDULL,
1655 0x00FDFDFDFDFDFDFDULL,
1656 0xFDFDFDFDFDFDFDFDULL,
1657 0xFDFDFDFDFDFDFDFDULL,
1658 0xFDFDFDFDFDFDFDFDULL,
1659 0xFDFDFDFDFDFDFDFDULL,
1660 0xFDFDFDFDFDFDFDFDULL
1661 },
1662 {
1663 0x0000FDFDFDFDFDFDULL,
1664 0x00FDFDFDFDFDFDFDULL,
1665 0xFDFDFDFDFDFDFDFDULL,
1666 0xFDFDFDFDFDFDFDFDULL,
1667 0xFDFDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL
1671 },
1672 {
1673 0x00FDFDFDFDFDFDFDULL,
1674 0xFDFDFDFDFDFDFDFDULL,
1675 0xFDFDFDFDFDFDFDFDULL,
1676 0xFDFDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL
1681 },
1682 {
1683 0xFDFDFDFDFDFDFDFDULL,
1684 0xFDFDFDFDFDFDFDFDULL,
1685 0xFDFDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL
1691 }
1692 }
1693 };
1694
1695 int32_t black_opening_count=0;
1696 int32_t black_opening_x,black_opening_y;
1697 int32_t black_opening_shape;
1698
1699 80 int32_t choose_opening_shape()
1700 {
1701 // First, count how many bits are set
1702 80 int32_t numBits=0;
1703 int32_t bitCounter;
1704
1705
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 80 times.
480 for(int32_t i=0; i<bosMAX; i++)
1706 {
1707
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 80 times.
400 if(COOLSCROLL&(1<<i))
1708 80 numBits++;
1709 400 }
1710
1711 // Shouldn't happen...
1712
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if(numBits==0)
1713 return bosCIRCLE;
1714
1715 // Pick a bit
1716 80 bitCounter=zc_rand()%numBits+1;
1717
1718
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 for(int32_t i=0; i<bosMAX; i++)
1719 {
1720 // If this bit is set, decrement the bit counter
1721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(COOLSCROLL&(1<<i))
1722 80 bitCounter--;
1723
1724 // When the counter hits 0, return a value based on
1725 // which bit it stopped on.
1726 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1727
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if(bitCounter==0)
1728 80 return i;
1729 }
1730
1731 // Shouldn't be necessary, but the compiler might complain, at least
1732 return bosCIRCLE;
1733 80 }
1734
1735 24 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1736 {
1737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1738
1739 24 int32_t w=256, h=224;
1740 24 int32_t blockrows=28, blockcolumns=32;
1741 24 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1742
1743
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 24 times.
696 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1744 {
1745
2/2
✓ Branch 0 taken 21504 times.
✓ Branch 1 taken 672 times.
22176 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1746 {
1747
2/2
✓ Branch 0 taken 11291 times.
✓ Branch 1 taken 10213 times.
21504 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1748 21504 }
1749 672 }
1750
1751 24 black_opening_count = 66;
1752 24 black_opening_x = x;
1753 24 black_opening_y = y;
1754 24 lensclk = 0;
1755 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1756
1757
1758
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(black_opening_shape == bosFADEBLACK)
1759 {
1760 refreshTints();
1761 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1762 }
1763
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(wait)
1764 {
1765 FFCore.warpScriptCheck();
1766 for(int32_t i=0; i<66; i++)
1767 {
1768 draw_screen(tmpscr);
1769 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1770 syskeys();
1771 advanceframe(true);
1772
1773 if(Quit)
1774 {
1775 break;
1776 }
1777 }
1778 }
1779 24 }
1780
1781 56 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1782 {
1783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1784
1785 56 int32_t w=256, h=224;
1786 56 int32_t blockrows=28, blockcolumns=32;
1787 56 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1788
1789
2/2
✓ Branch 0 taken 1568 times.
✓ Branch 1 taken 56 times.
1624 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1790 {
1791
2/2
✓ Branch 0 taken 50176 times.
✓ Branch 1 taken 1568 times.
51744 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1792 {
1793
2/2
✓ Branch 0 taken 21441 times.
✓ Branch 1 taken 28735 times.
50176 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1794 50176 }
1795 1568 }
1796
1797 56 black_opening_count = -66;
1798 56 black_opening_x = x;
1799 56 black_opening_y = y;
1800 56 lensclk = 0;
1801
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(black_opening_shape == bosFADEBLACK)
1802 {
1803 refreshTints();
1804 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1805 }
1806
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 38 times.
56 if(wait)
1807 {
1808 38 FFCore.warpScriptCheck();
1809
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 2508 times.
2546 for(int32_t i=0; i<66; i++)
1810 {
1811 2508 draw_screen(tmpscr);
1812 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1813 2508 syskeys();
1814 2508 advanceframe(true);
1815
1816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2508 times.
2508 if(Quit)
1817 {
1818 break;
1819 }
1820 2508 }
1821 38 }
1822 56 }
1823
1824 5280 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1825 {
1826 5280 clear_to_color(tmp_scr,BLACK);
1827 5280 int32_t w=256, h=224;
1828
1829
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5280 times.
5280 switch(black_opening_shape)
1830 {
1831 case bosOVAL:
1832 {
1833 double new_w=(w/2)+abs(w/2-x);
1834 double new_h=(h/2)+abs(h/2-y);
1835 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1836 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1837 break;
1838 }
1839
1840 case bosTRIANGLE:
1841 {
1842 double new_w=(w/2)+abs(w/2-x);
1843 double new_h=(h/2)+abs(h/2-y);
1844 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1845 double P2= (PI/2);
1846 double P23=(2*PI/3);
1847 double P43=(4*PI/3);
1848 double Pa= (-4*PI*a/(3*max_a));
1849 double angle=P2+Pa;
1850 double a0=angle;
1851 double a2=angle+P23;
1852 double a4=angle+P43;
1853 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1854 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1855 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1856 0);
1857 break;
1858 }
1859
1860 case bosSMAS:
1861 {
1862 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1863
1864 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1865 {
1866 for(int32_t linerow=0; linerow<8; ++linerow)
1867 {
1868 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1869
1870 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1871 {
1872 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1873 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1874 [linerow];
1875 ++triangleline;
1876
1877 if(linerow==0)
1878 {
1879 }
1880 }
1881 }
1882 }
1883
1884 break;
1885 }
1886
1887 case bosFADEBLACK:
1888 {
1889 if(black_opening_count<0)
1890 {
1891 black_fade(zc_min(-black_opening_count,63));
1892 }
1893 else if(black_opening_count>0)
1894 {
1895 black_fade(63-zc_max(black_opening_count-3,0));
1896 }
1897 else black_fade(0);
1898 return; //no blitting from tmp_scr!
1899 }
1900
1901 5280 case bosCIRCLE:
1902 default:
1903 {
1904 5280 double new_w=(w/2)+abs(w/2-x);
1905 5280 double new_h=(h/2)+abs(h/2-y);
1906 5280 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1907 //circlefill(tmp_scr,x,y,a<<3,0);
1908 5280 circlefill(tmp_scr,x,y,r,0);
1909 5280 break;
1910 }
1911 }
1912
1913 5280 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1914 5280 }
1915
1916
1917 void black_fade(int32_t fadeamnt)
1918 {
1919 for(int32_t i=0; i < 0xEF; i++)
1920 {
1921 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1922 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1923 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1924 }
1925
1926 refreshpal = true;
1927 }
1928
1929 //----------------------------------------------------------------
1930
1931 240203 bool item_disabled(int32_t item) //is this item disabled?
1932 {
1933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240203 times.
240203 return (item>=0 && game->items_off[item] != 0);
1934 }
1935
1936 733334 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1937 {
1938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 733334 times.
733334 if(current_item(item_type, true) >=item)
1939 {
1940 return true;
1941 }
1942
1943 733334 return false;
1944 733334 }
1945
1946 3609473 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1947 {
1948
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 536130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 315882 times.
✓ Branch 6 taken 2075964 times.
✓ Branch 7 taken 678496 times.
✓ Branch 8 taken 3001 times.
3609473 switch(item_type)
1949 {
1950 case itype_bomb:
1951 case itype_sbomb:
1952 {
1953 int32_t itemid = getItemID(itemsbuf, item_type, it);
1954
1955 if(itemid == -1)
1956 return false;
1957
1958 return (game->get_item(itemid));
1959 }
1960
1961 case itype_clock:
1962 {
1963 536130 int32_t itemid = getItemID(itemsbuf, item_type, it);
1964
1965
2/4
✓ Branch 0 taken 536130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 536130 times.
✗ Branch 3 not taken.
536130 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1966 return (game->get_item(itemid));
1967 536130 return Hero.getClock()?1:0;
1968 }
1969
1970 case itype_key:
1971 return (game->get_keys()>0);
1972
1973 case itype_magiccontainer:
1974 return (game->get_maxmagic()>=game->get_mp_per_block());
1975
1976 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1977 {
1978
1/3
✓ Branch 0 taken 315882 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
315882 switch(it)
1979 {
1980 case -2:
1981 {
1982 for(int32_t i=0; i<MAXLEVELS; i++)
1983 {
1984 if(game->lvlitems[i]&liTRIFORCE)
1985 {
1986 return true;
1987 }
1988 }
1989
1990 return false;
1991 }
1992
1993 case -1:
1994 return (game->lvlitems[dlevel]&liTRIFORCE);
1995
1996 default:
1997
2/4
✓ Branch 0 taken 315882 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 315882 times.
315882 if(it>=0&&it<MAXLEVELS)
1998 {
1999 315882 return (game->lvlitems[it]&liTRIFORCE);
2000 }
2001
2002 break;
2003 }
2004
2005 return 0;
2006 }
2007
2008 case itype_map: //it: -2=any, -1=current level, other=that level
2009 {
2010
1/3
✓ Branch 0 taken 2075964 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2075964 switch(it)
2011 {
2012 case -2:
2013 {
2014 for(int32_t i=0; i<MAXLEVELS; i++)
2015 {
2016 if(game->lvlitems[i]&liMAP)
2017 {
2018 return true;
2019 }
2020 }
2021
2022 return false;
2023 }
2024
2025 case -1:
2026 return (game->lvlitems[dlevel]&liMAP)!=0;
2027
2028 default:
2029
2/4
✓ Branch 0 taken 2075964 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2075964 times.
2075964 if(it>=0&&it<MAXLEVELS)
2030 {
2031 2075964 return (game->lvlitems[it]&liMAP)!=0;
2032 }
2033
2034 break;
2035 }
2036
2037 return 0;
2038 }
2039
2040 case itype_compass: //it: -2=any, -1=current level, other=that level
2041 {
2042
1/3
✓ Branch 0 taken 678496 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
678496 switch(it)
2043 {
2044 case -2:
2045 {
2046 for(int32_t i=0; i<MAXLEVELS; i++)
2047 {
2048 if(game->lvlitems[i]&liCOMPASS)
2049 {
2050 return true;
2051 }
2052 }
2053
2054 return false;
2055 }
2056
2057 case -1:
2058 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2059
2060 default:
2061
2/4
✓ Branch 0 taken 678496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 678496 times.
✗ Branch 3 not taken.
678496 if(it>=0&&it<MAXLEVELS)
2062 {
2063 678496 return (game->lvlitems[it]&liCOMPASS)!=0;
2064 }
2065
2066 break;
2067 }
2068 return 0;
2069 }
2070
2071 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2072 {
2073
1/3
✓ Branch 0 taken 3001 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3001 switch(it)
2074 {
2075 case -2:
2076 {
2077 for(int32_t i=0; i<MAXLEVELS; i++)
2078 {
2079 if(game->lvlitems[i]&liBOSSKEY)
2080 {
2081 return true;
2082 }
2083 }
2084
2085 return false;
2086 }
2087
2088 case -1:
2089 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2090
2091 default:
2092
2/4
✓ Branch 0 taken 3001 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3001 times.
3001 if(it>=0&&it<MAXLEVELS)
2093 {
2094 3001 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2095 }
2096 break;
2097 }
2098 return 0;
2099 }
2100
2101 default:
2102 //it=(1<<(it-1));
2103 /*if (item_type>=itype_max)
2104 {
2105 system_pal();
2106 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2107 game_pal();
2108
2109 return false;
2110 }*/
2111 int32_t itemid = getItemID(itemsbuf, item_type, it);
2112
2113 if(itemid == -1)
2114 return false;
2115
2116 return game->get_item(itemid);
2117 }
2118 3609473 }
2119
2120
2121 8982240 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2122 {
2123
9/9
✓ Branch 0 taken 536130 times.
✓ Branch 1 taken 4693200 times.
✓ Branch 2 taken 536130 times.
✓ Branch 3 taken 536130 times.
✓ Branch 4 taken 536130 times.
✓ Branch 5 taken 536130 times.
✓ Branch 6 taken 536130 times.
✓ Branch 7 taken 536130 times.
✓ Branch 8 taken 536130 times.
8982240 switch(item_type)
2124 {
2125 case itype_clock:
2126 {
2127 536130 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2128
2129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 536130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
536130 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2130 return itemsbuf[maxid].fam_type;
2131
2132 536130 return has_item(itype_clock,1) ? 1 : 0;
2133 }
2134
2135 case itype_key:
2136 536130 return game->get_keys();
2137
2138 case itype_lkey:
2139 536130 return game->lvlkeys[get_dlevel()];
2140
2141 case itype_magiccontainer:
2142 536130 return game->get_maxmagic()/game->get_mp_per_block();
2143
2144 case itype_triforcepiece:
2145 {
2146 536130 int32_t count=0;
2147
2148
2/2
✓ Branch 0 taken 274498560 times.
✓ Branch 1 taken 536130 times.
275034690 for(int32_t i=0; i<MAXLEVELS; i++)
2149 {
2150 274498560 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2151 274498560 }
2152
2153 536130 return count;
2154 }
2155
2156 case itype_map:
2157 {
2158 536130 int32_t count=0;
2159
2160
2/2
✓ Branch 0 taken 274498560 times.
✓ Branch 1 taken 536130 times.
275034690 for(int32_t i=0; i<MAXLEVELS; i++)
2161 {
2162 274498560 count+=(game->lvlitems[i]&liMAP)?1:0;
2163 274498560 }
2164
2165 536130 return count;
2166 }
2167
2168 case itype_compass:
2169 {
2170 536130 int32_t count=0;
2171
2172
2/2
✓ Branch 0 taken 274498560 times.
✓ Branch 1 taken 536130 times.
275034690 for(int32_t i=0; i<MAXLEVELS; i++)
2173 {
2174 274498560 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2175 274498560 }
2176
2177 536130 return count;
2178 }
2179
2180 case itype_bosskey:
2181 {
2182 536130 int32_t count=0;
2183
2184
2/2
✓ Branch 0 taken 274498560 times.
✓ Branch 1 taken 536130 times.
275034690 for(int32_t i=0; i<MAXLEVELS; i++)
2185 {
2186 274498560 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2187 274498560 }
2188
2189 536130 return count;
2190 }
2191
2192 default:
2193 4693200 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2194
2195
2/2
✓ Branch 0 taken 143285 times.
✓ Branch 1 taken 4549915 times.
4693200 if(maxid == -1)
2196 4549915 return 0;
2197
2198 143285 return itemsbuf[maxid].fam_type;
2199 }
2200 8982240 }
2201
2202 8248906 int32_t current_item(int32_t item_type) //item currently being used
2203 {
2204 8248906 return current_item(item_type, true);
2205 }
2206
2207 11 std::map<int32_t, int32_t> itemcache;
2208
2209 // Not actually used by anything at the moment...
2210 void removeFromItemCache(int32_t itemid)
2211 {
2212 itemcache.erase(itemid);
2213 }
2214
2215 1567 void flushItemCache()
2216 {
2217 1567 itemcache.clear();
2218
2219 //also fix the active subscreen if items were deleted -DD
2220
1/2
✓ Branch 0 taken 1567 times.
✗ Branch 1 not taken.
1567 if(game != NULL)
2221 {
2222 1567 verifyBothWeapons();
2223 1567 load_Sitems(&QMisc);
2224 1567 }
2225 1567 }
2226
2227 // This is used often, so it should be as direct as possible.
2228 295663113 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2229 {
2230
2/2
✓ Branch 0 taken 290917829 times.
✓ Branch 1 taken 4745284 times.
295663113 if(jinx_check)
2231 {
2232
4/4
✓ Branch 0 taken 3311719 times.
✓ Branch 1 taken 1433565 times.
✓ Branch 2 taken 3208176 times.
✓ Branch 3 taken 103543 times.
4745284 if(!(HeroSwordClk() || HeroItemClk()))
2233 3208176 jinx_check = false; //not jinxed
2234 4745284 }
2235
4/4
✓ Branch 0 taken 294033588 times.
✓ Branch 1 taken 1629525 times.
✓ Branch 2 taken 1529625 times.
✓ Branch 3 taken 292503963 times.
295663113 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2236 {
2237 292503963 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2238
2239
2/2
✓ Branch 0 taken 291703860 times.
✓ Branch 1 taken 800103 times.
292503963 if(res != itemcache.end())
2240 291703860 return res->second;
2241 800103 }
2242
2243 3959253 int32_t result = -1;
2244 3959253 int32_t highestlevel = -1;
2245
2246
2/2
✓ Branch 0 taken 1013568768 times.
✓ Branch 1 taken 3959253 times.
1017528021 for(int32_t i=0; i<MAXITEMS; i++)
2247 {
2248
5/6
✓ Branch 0 taken 39833833 times.
✓ Branch 1 taken 973734935 times.
✓ Branch 2 taken 226526 times.
✓ Branch 3 taken 39607307 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226526 times.
1013568768 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2249 {
2250
4/4
✓ Branch 0 taken 97564 times.
✓ Branch 1 taken 128962 times.
✓ Branch 2 taken 48243 times.
✓ Branch 3 taken 178283 times.
226526 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2251 {
2252 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2253
2/2
✓ Branch 0 taken 178252 times.
✓ Branch 1 taken 31 times.
178283 if(!checkmagiccost(i))
2254 {
2255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2256 }
2257 178252 }
2258
6/6
✓ Branch 0 taken 131447 times.
✓ Branch 1 taken 95048 times.
✓ Branch 2 taken 17461 times.
✓ Branch 3 taken 77587 times.
✓ Branch 4 taken 73291 times.
✓ Branch 5 taken 21757 times.
226495 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2259 {
2260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21757 times.
21757 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2261 21757 continue;
2262 }
2263
2264
2/2
✓ Branch 0 taken 19193 times.
✓ Branch 1 taken 185545 times.
204738 if(itemsbuf[i].fam_type >= highestlevel)
2265 {
2266 185545 highestlevel = itemsbuf[i].fam_type;
2267 185545 result=i;
2268 185545 }
2269 204738 }
2270 1013546980 }
2271
2272
2/2
✓ Branch 0 taken 1537108 times.
✓ Branch 1 taken 2422145 times.
3959253 if(!jinx_check) //Can't cache jinx_check results
2273 2422145 itemcache[itemtype] = result;
2274 3959253 return result;
2275 295663113 }
2276
2277 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2278 294147881 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2279 {
2280 294147881 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2281
2/2
✓ Branch 0 taken 3230052 times.
✓ Branch 1 taken 290917829 times.
294147881 if(!jinx_check) //If not already a jinx-immune-only check...
2282 {
2283 //And the player IS jinxed...
2284
4/4
✓ Branch 0 taken 289504728 times.
✓ Branch 1 taken 1413101 times.
✓ Branch 2 taken 102131 times.
✓ Branch 3 taken 289402597 times.
290917829 if(HeroSwordClk() || HeroItemClk())
2285 {
2286 //Then do a jinx-immune-only check here
2287 1515232 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2288 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2289 //Should NOT need a compat rule, as this should always return -1 in old quests.
2290
2/2
✓ Branch 0 taken 39576 times.
✓ Branch 1 taken 1475656 times.
1515232 if(ret2 > -1) return ret2;
2291 1475656 }
2292 290878253 }
2293 294108305 return ret;
2294 294147881 }
2295 2098754 int32_t current_item_power(int32_t itemtype)
2296 {
2297 2098754 int32_t result = current_item_id(itemtype,true);
2298
2/2
✓ Branch 0 taken 2053091 times.
✓ Branch 1 taken 45663 times.
2098754 return (result<0) ? 0 : itemsbuf[result].power;
2299 }
2300
2301 int32_t heart_container_id()
2302 {
2303 for(int32_t i=0; i<MAXITEMS; i++)
2304 {
2305 if(itemsbuf[i].family == itype_heartcontainer)
2306 {
2307 return i;
2308 }
2309 }
2310 return -1;
2311 }
2312
2313 536130 int32_t item_tile_mod()
2314 {
2315 536130 int32_t tile=0;
2316
2317
2/2
✓ Branch 0 taken 64903 times.
✓ Branch 1 taken 471227 times.
536130 if(game->get_bombs())
2318 {
2319 471227 int32_t itemid = current_item_id(itype_bomb,false);
2320
3/4
✓ Branch 0 taken 470858 times.
✓ Branch 1 taken 369 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 470858 times.
471227 if(itemid > -1 && checkbunny(itemid))
2321 470858 tile+=itemsbuf[itemid].ltm;
2322 471227 }
2323
2324
2/2
✓ Branch 0 taken 525336 times.
✓ Branch 1 taken 10794 times.
536130 if(game->get_sbombs())
2325 {
2326 10794 int32_t itemid = current_item_id(itype_sbomb,false);
2327
3/4
✓ Branch 0 taken 4127 times.
✓ Branch 1 taken 6667 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4127 times.
10794 if(itemid > -1 && checkbunny(itemid))
2328 4127 tile+=itemsbuf[itemid].ltm;
2329 10794 }
2330
2331
2/2
✓ Branch 0 taken 526672 times.
✓ Branch 1 taken 9458 times.
536130 if(current_item(itype_clock))
2332 {
2333 9458 int32_t itemid =
2334
1/2
✓ Branch 0 taken 9458 times.
✗ Branch 1 not taken.
9458 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2335 ? iClock
2336 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2337
2/4
✓ Branch 0 taken 9458 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9458 times.
9458 if(itemid > -1 && checkbunny(itemid))
2338 9458 tile+=itemsbuf[itemid].ltm;
2339 9458 }
2340
2341
2/2
✓ Branch 0 taken 356424 times.
✓ Branch 1 taken 179706 times.
536130 if(current_item(itype_key))
2342 {
2343 179706 int32_t itemid =
2344
1/2
✓ Branch 0 taken 179706 times.
✗ Branch 1 not taken.
179706 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2345 ? iKey
2346 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2347
2/4
✓ Branch 0 taken 179706 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 179706 times.
179706 if(itemid > -1 && checkbunny(itemid))
2348 179706 tile+=itemsbuf[itemid].ltm;
2349 179706 }
2350
2351
2/2
✓ Branch 0 taken 485893 times.
✓ Branch 1 taken 50237 times.
536130 if(current_item(itype_lkey))
2352 {
2353 50237 int32_t itemid =
2354
1/2
✓ Branch 0 taken 50237 times.
✗ Branch 1 not taken.
50237 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2355 ? iLevelKey
2356 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2357
2/4
✓ Branch 0 taken 50237 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50237 times.
50237 if(itemid > -1 && checkbunny(itemid))
2358 50237 tile+=itemsbuf[itemid].ltm;
2359 50237 }
2360
2361
2/2
✓ Branch 0 taken 143395 times.
✓ Branch 1 taken 392735 times.
536130 if(current_item(itype_map))
2362 {
2363 392735 int32_t itemid =
2364
1/2
✓ Branch 0 taken 392735 times.
✗ Branch 1 not taken.
392735 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2365 ? iMap
2366 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2367
2/4
✓ Branch 0 taken 392735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 392735 times.
392735 if(itemid > -1 && checkbunny(itemid))
2368 392735 tile+=itemsbuf[itemid].ltm;
2369 392735 }
2370
2371
2/2
✓ Branch 0 taken 80101 times.
✓ Branch 1 taken 456029 times.
536130 if(current_item(itype_compass))
2372 {
2373 456029 int32_t itemid =
2374
1/2
✓ Branch 0 taken 456029 times.
✗ Branch 1 not taken.
456029 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2375 ? iCompass
2376 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2377
2/4
✓ Branch 0 taken 456029 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 456029 times.
456029 if(itemid > -1 && checkbunny(itemid))
2378 456029 tile+=itemsbuf[itemid].ltm;
2379 456029 }
2380
2381
2/2
✓ Branch 0 taken 267422 times.
✓ Branch 1 taken 268708 times.
536130 if(current_item(itype_bosskey))
2382 {
2383 268708 int32_t itemid =
2384
1/2
✓ Branch 0 taken 268708 times.
✗ Branch 1 not taken.
268708 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2385 ? iBossKey
2386 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2387
2/4
✓ Branch 0 taken 268708 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 268708 times.
268708 if(itemid > -1 && checkbunny(itemid))
2388 268708 tile+=itemsbuf[itemid].ltm;
2389 268708 }
2390
2391
1/2
✓ Branch 0 taken 536130 times.
✗ Branch 1 not taken.
536130 if(current_item(itype_magiccontainer))
2392 {
2393 int32_t itemid =
2394 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2395 ? iMagicC
2396 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2397 if(itemid > -1 && checkbunny(itemid))
2398 tile+=itemsbuf[itemid].ltm;
2399 }
2400
2401
2/2
✓ Branch 0 taken 90640 times.
✓ Branch 1 taken 445490 times.
536130 if(current_item(itype_triforcepiece))
2402 {
2403 445490 int32_t itemid =
2404
1/2
✓ Branch 0 taken 445490 times.
✗ Branch 1 not taken.
445490 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2405 ? iTriforce
2406 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2407
2/4
✓ Branch 0 taken 445490 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 445490 times.
445490 if(itemid > -1 && checkbunny(itemid))
2408 445490 tile+=itemsbuf[itemid].ltm;
2409 445490 }
2410
2411
2/2
✓ Branch 0 taken 536130 times.
✓ Branch 1 taken 274498560 times.
275034690 for(int32_t i=0; i<itype_max; i++)
2412 {
2413
2/2
✓ Branch 0 taken 269011456 times.
✓ Branch 1 taken 5487104 times.
274498560 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2414 {
2415
2/2
✓ Branch 0 taken 107170 times.
✓ Branch 1 taken 5379934 times.
5487104 switch(i)
2416 {
2417 case itype_bomb:
2418 case itype_sbomb:
2419 case itype_clock:
2420 case itype_key:
2421 case itype_lkey:
2422 case itype_map:
2423 case itype_compass:
2424 case itype_bosskey:
2425 case itype_magiccontainer:
2426 case itype_triforcepiece:
2427 107170 continue; //already handled
2428 }
2429 5379934 }
2430 274391390 int32_t itemid = current_item_id(i,false);
2431
2/2
✓ Branch 0 taken 273855260 times.
✓ Branch 1 taken 536130 times.
274391390 if(i == itype_shield)
2432 536130 itemid = getCurrentShield(false);
2433
2434
3/4
✓ Branch 0 taken 3869137 times.
✓ Branch 1 taken 270522253 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3869137 times.
274391390 if(itemid < 0 || !checkbunny(itemid))
2435 270522253 continue;
2436
2437 3869137 itemdata const& itm = itemsbuf[itemid];
2438
2439
2/2
✓ Branch 0 taken 3333007 times.
✓ Branch 1 taken 536130 times.
3869137 switch(itm.family)
2440 {
2441 case itype_shield:
2442
1/2
✓ Branch 0 taken 536130 times.
✗ Branch 1 not taken.
536130 if(itm.flags & ITEM_FLAG9) //active shield
2443 {
2444 if(!usingActiveShield(itemid))
2445 {
2446 tile+=itm.misc6; //'Inactive PTM'
2447 continue;
2448 }
2449 }
2450 536130 break;
2451 }
2452
2453 3869137 tile+=itm.ltm;
2454 3869137 }
2455
2456 536130 return tile;
2457 }
2458
2459 536130 int32_t bunny_tile_mod()
2460 {
2461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 536130 times.
536130 if(Hero.BunnyClock())
2462 {
2463 return game->get_bunny_ltm();
2464 }
2465 536130 return 0;
2466 536130 }
2467
2468 // Hints are drawn on a separate layer to combo reveals.
2469 void draw_lens_under(BITMAP *dest, bool layer)
2470 {
2471 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2472 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2473 //Lens flag 3: Don't show armos/chest/dive items
2474 //Lens flag 4: Show Raft Paths
2475 //Lens flag 5: Show Invisible Enemies
2476 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2477
2478 int32_t strike_hint_table[11]=
2479 {
2480 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2481 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2482 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2483 };
2484
2485 // int32_t page = tmpscr->cpage;
2486 {
2487 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2488 // int32_t temptimer=0;
2489 int32_t tempitem, tempweapon=0;
2490 strike_hint=strike_hint_table[strike_hint_counter];
2491
2492 if(strike_hint_timer>32)
2493 {
2494 strike_hint_timer=0;
2495 strike_hint_counter=((strike_hint_counter+1)%11);
2496 }
2497
2498 ++strike_hint_timer;
2499
2500 for(int32_t i=0; i<176; i++)
2501 {
2502 int32_t x = (i & 15) << 4;
2503 int32_t y = (i & 0xF0) + playing_field_offset;
2504 int32_t tempitemx=-16, tempitemy=-16;
2505 int32_t tempweaponx=-16, tempweapony=-16;
2506
2507 for(int32_t iter=0; iter<2; ++iter)
2508 {
2509 int32_t checkflag=0;
2510
2511 if(iter==0)
2512 {
2513 checkflag=combobuf[tmpscr->data[i]].flag;
2514 }
2515 else
2516 {
2517 checkflag=tmpscr->sflag[i];
2518 }
2519
2520 if(checkflag==mfSTRIKE)
2521 {
2522 if(!hints)
2523 {
2524 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2525 }
2526 else
2527 {
2528 checkflag = strike_hint;
2529 }
2530 }
2531
2532 switch(checkflag)
2533 {
2534 case 0:
2535 case mfZELDA:
2536 case mfPUSHED:
2537 case mfENEMY0:
2538 case mfENEMY1:
2539 case mfENEMY2:
2540 case mfENEMY3:
2541 case mfENEMY4:
2542 case mfENEMY5:
2543 case mfENEMY6:
2544 case mfENEMY7:
2545 case mfENEMY8:
2546 case mfENEMY9:
2547 case mfSINGLE:
2548 case mfSINGLE16:
2549 case mfNOENEMY:
2550 case mfTRAP_H:
2551 case mfTRAP_V:
2552 case mfTRAP_4:
2553 case mfTRAP_LR:
2554 case mfTRAP_UD:
2555 case mfNOGROUNDENEMY:
2556 case mfNOBLOCKS:
2557 case mfSCRIPT1:
2558 case mfSCRIPT2:
2559 case mfSCRIPT3:
2560 case mfSCRIPT4:
2561 case mfSCRIPT5:
2562 case mfSCRIPT6:
2563 case mfSCRIPT7:
2564 case mfSCRIPT8:
2565 case mfSCRIPT9:
2566 case mfSCRIPT10:
2567 case mfSCRIPT11:
2568 case mfSCRIPT12:
2569 case mfSCRIPT13:
2570 case mfSCRIPT14:
2571 case mfSCRIPT15:
2572 case mfSCRIPT16:
2573 case mfSCRIPT17:
2574 case mfSCRIPT18:
2575 case mfSCRIPT19:
2576 case mfSCRIPT20:
2577 case mfPITHOLE:
2578 case mfPITFALLFLOOR:
2579 case mfLAVA:
2580 case mfICE:
2581 case mfICEDAMAGE:
2582 case mfDAMAGE1:
2583 case mfDAMAGE2:
2584 case mfDAMAGE4:
2585 case mfDAMAGE8:
2586 case mfDAMAGE16:
2587 case mfDAMAGE32:
2588 case mfFREEZEALL:
2589 case mfFREZEALLANSFFCS:
2590 case mfFREEZEFFCSOLY:
2591 case mfSCRITPTW1TRIG:
2592 case mfSCRITPTW2TRIG:
2593 case mfSCRITPTW3TRIG:
2594 case mfSCRITPTW4TRIG:
2595 case mfSCRITPTW5TRIG:
2596 case mfSCRITPTW6TRIG:
2597 case mfSCRITPTW7TRIG:
2598 case mfSCRITPTW8TRIG:
2599 case mfSCRITPTW9TRIG:
2600 case mfSCRITPTW10TRIG:
2601 case mfTROWEL:
2602 case mfTROWELNEXT:
2603 case mfTROWELSPECIALITEM:
2604 case mfSLASHPOT:
2605 case mfLIFTPOT:
2606 case mfLIFTORSLASH:
2607 case mfLIFTROCK:
2608 case mfLIFTROCKHEAVY:
2609 case mfDROPITEM:
2610 case mfSPECIALITEM:
2611 case mfDROPKEY:
2612 case mfDROPLKEY:
2613 case mfDROPCOMPASS:
2614 case mfDROPMAP:
2615 case mfDROPBOSSKEY:
2616 case mfSPAWNNPC:
2617 case mfSWITCHHOOK:
2618 case mfSIDEVIEWLADDER:
2619 case mfSIDEVIEWPLATFORM:
2620 case mfNOENEMYSPAWN:
2621 case mfENEMYALL:
2622 case mfNOMIRROR:
2623 case mfUNSAFEGROUND:
2624 case mf168:
2625 case mf169:
2626 case mf170:
2627 case mf171:
2628 case mf172:
2629 case mf173:
2630 case mf174:
2631 case mf175:
2632 case mf176:
2633 case mf177:
2634 case mf178:
2635 case mf179:
2636 case mf180:
2637 case mf181:
2638 case mf182:
2639 case mf183:
2640 case mf184:
2641 case mf185:
2642 case mf186:
2643 case mf187:
2644 case mf188:
2645 case mf189:
2646 case mf190:
2647 case mf191:
2648 case mf192:
2649 case mf193:
2650 case mf194:
2651 case mf195:
2652 case mf196:
2653 case mf197:
2654 case mf198:
2655 case mf199:
2656 case mf200:
2657 case mf201:
2658 case mf202:
2659 case mf203:
2660 case mf204:
2661 case mf205:
2662 case mf206:
2663 case mf207:
2664 case mf208:
2665 case mf209:
2666 case mf210:
2667 case mf211:
2668 case mf212:
2669 case mf213:
2670 case mf214:
2671 case mf215:
2672 case mf216:
2673 case mf217:
2674 case mf218:
2675 case mf219:
2676 case mf220:
2677 case mf221:
2678 case mf222:
2679 case mf223:
2680 case mf224:
2681 case mf225:
2682 case mf226:
2683 case mf227:
2684 case mf228:
2685 case mf229:
2686 case mf230:
2687 case mf231:
2688 case mf232:
2689 case mf233:
2690 case mf234:
2691 case mf235:
2692 case mf236:
2693 case mf237:
2694 case mf238:
2695 case mf239:
2696 case mf240:
2697 case mf241:
2698 case mf242:
2699 case mf243:
2700 case mf244:
2701 case mf245:
2702 case mf246:
2703 case mf247:
2704 case mf248:
2705 case mf249:
2706 case mf250:
2707 case mf251:
2708 case mf252:
2709 case mf253:
2710 case mf254:
2711 case mfEXTENDED:
2712 break;
2713
2714 case mfPUSHUD:
2715 case mfPUSHLR:
2716 case mfPUSH4:
2717 case mfPUSHU:
2718 case mfPUSHD:
2719 case mfPUSHL:
2720 case mfPUSHR:
2721 case mfPUSHUDNS:
2722 case mfPUSHLRNS:
2723 case mfPUSH4NS:
2724 case mfPUSHUNS:
2725 case mfPUSHDNS:
2726 case mfPUSHLNS:
2727 case mfPUSHRNS:
2728 case mfPUSHUDINS:
2729 case mfPUSHLRINS:
2730 case mfPUSH4INS:
2731 case mfPUSHUINS:
2732 case mfPUSHDINS:
2733 case mfPUSHLINS:
2734 case mfPUSHRINS:
2735 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2736 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2737 {
2738 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2739 }
2740
2741 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2742 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2743 {
2744 if(hints)
2745 {
2746 switch(combobuf[tmpscr->data[i]].type)
2747 {
2748 case cPUSH_HEAVY:
2749 case cPUSH_HW:
2750 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2751 tempitemx=x, tempitemy=y;
2752
2753 if(tempitem>-1)
2754 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2755
2756 break;
2757
2758 case cPUSH_HEAVY2:
2759 case cPUSH_HW2:
2760 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2761 tempitemx=x, tempitemy=y;
2762
2763 if(tempitem>-1)
2764 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2765
2766 break;
2767 }
2768 }
2769 }
2770
2771 break;
2772
2773 case mfWHISTLE:
2774 if(hints)
2775 {
2776 tempitem=getItemID(itemsbuf,itype_whistle,1);
2777
2778 if(tempitem<0) break;
2779
2780 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2781 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2782 {
2783 tempitemx=x;
2784 tempitemy=y;
2785 }
2786
2787 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2788 }
2789
2790 break;
2791
2792 //Why is this here?
2793 case mfFAIRY:
2794 case mfMAGICFAIRY:
2795 case mfALLFAIRY:
2796 if(hints)
2797 {
2798 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2799
2800 if(tempitem < 0) break;
2801
2802 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2803 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2804 {
2805 tempitemx=x;
2806 tempitemy=y;
2807 }
2808
2809 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2810 }
2811
2812 break;
2813
2814 case mfBCANDLE:
2815 if(!hints)
2816 {
2817 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2818 }
2819 else
2820 {
2821 tempitem=getItemID(itemsbuf,itype_candle,1);
2822
2823 if(tempitem<0) break;
2824
2825 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2826 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2827 {
2828 tempitemx=x;
2829 tempitemy=y;
2830 }
2831
2832 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2833 }
2834
2835 break;
2836
2837 case mfRCANDLE:
2838 if(!hints)
2839 {
2840 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2841 }
2842 else
2843 {
2844 tempitem=getItemID(itemsbuf,itype_candle,2);
2845
2846 if(tempitem<0) break;
2847
2848 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2849 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2850 {
2851 tempitemx=x;
2852 tempitemy=y;
2853 }
2854
2855 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2856 }
2857
2858 break;
2859
2860 case mfWANDFIRE:
2861 if(!hints)
2862 {
2863 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2864 }
2865 else
2866 {
2867 tempitem=getItemID(itemsbuf,itype_wand,1);
2868
2869 if(tempitem<0) break;
2870
2871 tempweapon=wFire;
2872
2873 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2874 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2875 {
2876 tempitemx=x;
2877 tempitemy=y;
2878 }
2879 else
2880 {
2881 tempweaponx=x;
2882 tempweapony=y;
2883 }
2884
2885 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2886 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2887 }
2888
2889 break;
2890
2891 case mfDINSFIRE:
2892 if(!hints)
2893 {
2894 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2895 }
2896 else
2897 {
2898 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2899
2900 if(tempitem<0) break;
2901
2902 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2903 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2904 {
2905 tempitemx=x;
2906 tempitemy=y;
2907 }
2908
2909 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2910 }
2911
2912 break;
2913
2914 case mfARROW:
2915 if(!hints)
2916 {
2917 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2918 }
2919 else
2920 {
2921 tempitem=getItemID(itemsbuf,itype_arrow,1);
2922
2923 if(tempitem<0) break;
2924
2925 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2926 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2927 {
2928 tempitemx=x;
2929 tempitemy=y;
2930 }
2931
2932 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2933 }
2934
2935 break;
2936
2937 case mfSARROW:
2938 if(!hints)
2939 {
2940 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2941 }
2942 else
2943 {
2944 tempitem=getItemID(itemsbuf,itype_arrow,2);
2945
2946 if(tempitem<0) break;
2947
2948 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2949 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2950 {
2951 tempitemx=x;
2952 tempitemy=y;
2953 }
2954
2955 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2956 }
2957
2958 break;
2959
2960 case mfGARROW:
2961 if(!hints)
2962 {
2963 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2964 }
2965 else
2966 {
2967 tempitem=getItemID(itemsbuf,itype_arrow,3);
2968
2969 if(tempitem<0) break;
2970
2971 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2972 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2973 {
2974 tempitemx=x;
2975 tempitemy=y;
2976 }
2977
2978 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2979 }
2980
2981 break;
2982
2983 case mfBOMB:
2984 if(!hints)
2985 {
2986 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2987 }
2988 else
2989 {
2990 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2991 tempweapon = wLitBomb;
2992
2993 //if (tempitem<0) break;
2994 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2995 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2996 {
2997 tempweaponx=x;
2998 tempweapony=y;
2999 }
3000
3001 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3002 }
3003
3004 break;
3005
3006 case mfSBOMB:
3007 if(!hints)
3008 {
3009 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3010 }
3011 else
3012 {
3013 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3014 //if (tempitem<0) break;
3015 tempweapon = wLitSBomb;
3016
3017 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3018 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3019 {
3020 tempweaponx=x;
3021 tempweapony=y;
3022 }
3023
3024 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3025 }
3026
3027 break;
3028
3029 case mfARMOS_SECRET:
3030 if(!hints)
3031 {
3032 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3033 }
3034 break;
3035
3036 case mfBRANG:
3037 if(!hints)
3038 {
3039 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3040 }
3041 else
3042 {
3043 tempitem=getItemID(itemsbuf,itype_brang,1);
3044
3045 if(tempitem<0) break;
3046
3047 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3048 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3049 {
3050 tempitemx=x;
3051 tempitemy=y;
3052 }
3053
3054 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3055 }
3056
3057 break;
3058
3059 case mfMBRANG:
3060 if(!hints)
3061 {
3062 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3063 }
3064 else
3065 {
3066 tempitem=getItemID(itemsbuf,itype_brang,2);
3067
3068 if(tempitem<0) break;
3069
3070 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3071 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3072 {
3073 tempitemx=x;
3074 tempitemy=y;
3075 }
3076
3077 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3078 }
3079
3080 break;
3081
3082 case mfFBRANG:
3083 if(!hints)
3084 {
3085 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3086 }
3087 else
3088 {
3089 tempitem=getItemID(itemsbuf,itype_brang,3);
3090
3091 if(tempitem<0) break;
3092
3093 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3094 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3095 {
3096 tempitemx=x;
3097 tempitemy=y;
3098 }
3099
3100 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3101 }
3102
3103 break;
3104
3105 case mfWANDMAGIC:
3106 if(!hints)
3107 {
3108 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3109 }
3110 else
3111 {
3112 tempitem=getItemID(itemsbuf,itype_wand,1);
3113
3114 if(tempitem<0) break;
3115
3116 tempweapon=itemsbuf[tempitem].wpn3;
3117
3118 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3119 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3120 {
3121 tempitemx=x;
3122 tempitemy=y;
3123 }
3124 else
3125 {
3126 tempweaponx=x;
3127 tempweapony=y;
3128 --lens_hint_weapon[wMagic][4];
3129
3130 if(lens_hint_weapon[wMagic][4]<-8)
3131 {
3132 lens_hint_weapon[wMagic][4]=8;
3133 }
3134 }
3135
3136 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3137 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3138 }
3139
3140 break;
3141
3142 case mfREFMAGIC:
3143 if(!hints)
3144 {
3145 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3146 }
3147 else
3148 {
3149 tempitem=getItemID(itemsbuf,itype_shield,3);
3150
3151 if(tempitem<0) break;
3152
3153 tempweapon=ewMagic;
3154
3155 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3156 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3157 {
3158 tempitemx=x;
3159 tempitemy=y;
3160 }
3161 else
3162 {
3163 tempweaponx=x;
3164 tempweapony=y;
3165
3166 if(lens_hint_weapon[ewMagic][2]==up)
3167 {
3168 --lens_hint_weapon[ewMagic][4];
3169 }
3170 else
3171 {
3172 ++lens_hint_weapon[ewMagic][4];
3173 }
3174
3175 if(lens_hint_weapon[ewMagic][4]>8)
3176 {
3177 lens_hint_weapon[ewMagic][2]=up;
3178 }
3179
3180 if(lens_hint_weapon[ewMagic][4]<=0)
3181 {
3182 lens_hint_weapon[ewMagic][2]=down;
3183 }
3184 }
3185
3186 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3187 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3188 }
3189
3190 break;
3191
3192 case mfREFFIREBALL:
3193 if(!hints)
3194 {
3195 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3196 }
3197 else
3198 {
3199 tempitem=getItemID(itemsbuf,itype_shield,3);
3200
3201 if(tempitem<0) break;
3202
3203 tempweapon=ewFireball;
3204
3205 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3206 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3207 {
3208 tempitemx=x;
3209 tempitemy=y;
3210 tempweaponx=x;
3211 tempweapony=y;
3212 ++lens_hint_weapon[ewFireball][3];
3213
3214 if(lens_hint_weapon[ewFireball][3]>8)
3215 {
3216 lens_hint_weapon[ewFireball][3]=-8;
3217 lens_hint_weapon[ewFireball][4]=8;
3218 }
3219
3220 if(lens_hint_weapon[ewFireball][3]>0)
3221 {
3222 ++lens_hint_weapon[ewFireball][4];
3223 }
3224 else
3225 {
3226 --lens_hint_weapon[ewFireball][4];
3227 }
3228 }
3229
3230 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3231 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3232 }
3233
3234 break;
3235
3236 case mfSWORD:
3237 if(!hints)
3238 {
3239 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3240 }
3241 else
3242 {
3243 tempitem=getItemID(itemsbuf,itype_sword,1);
3244
3245 if(tempitem<0) break;
3246
3247 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3248 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3249 {
3250 tempitemx=x;
3251 tempitemy=y;
3252 }
3253
3254 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3255 }
3256
3257 break;
3258
3259 case mfWSWORD:
3260 if(!hints)
3261 {
3262 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3263 }
3264 else
3265 {
3266 tempitem=getItemID(itemsbuf,itype_sword,2);
3267
3268 if(tempitem<0) break;
3269
3270 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3271 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3272 {
3273 tempitemx=x;
3274 tempitemy=y;
3275 }
3276
3277 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3278 }
3279
3280 break;
3281
3282 case mfMSWORD:
3283 if(!hints)
3284 {
3285 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3286 }
3287 else
3288 {
3289 tempitem=getItemID(itemsbuf,itype_sword,3);
3290
3291 if(tempitem<0) break;
3292
3293 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3294 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3295 {
3296 tempitemx=x;
3297 tempitemy=y;
3298 }
3299
3300 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3301 }
3302
3303 break;
3304
3305 case mfXSWORD:
3306 if(!hints)
3307 {
3308 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3309 }
3310 else
3311 {
3312 tempitem=getItemID(itemsbuf,itype_sword,4);
3313
3314 if(tempitem<0) break;
3315
3316 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3317 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3318 {
3319 tempitemx=x;
3320 tempitemy=y;
3321 }
3322
3323 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3324 }
3325
3326 break;
3327
3328 case mfSWORDBEAM:
3329 if(!hints)
3330 {
3331 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3332 }
3333 else
3334 {
3335 tempitem=getItemID(itemsbuf,itype_sword,1);
3336
3337 if(tempitem<0) break;
3338
3339 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3340 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3341 {
3342 tempitemx=x;
3343 tempitemy=y;
3344 }
3345
3346 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3347 }
3348
3349 break;
3350
3351 case mfWSWORDBEAM:
3352 if(!hints)
3353 {
3354 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3355 }
3356 else
3357 {
3358 tempitem=getItemID(itemsbuf,itype_sword,2);
3359
3360 if(tempitem<0) break;
3361
3362 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3363 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3364 {
3365 tempitemx=x;
3366 tempitemy=y;
3367 }
3368
3369 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3370 }
3371
3372 break;
3373
3374 case mfMSWORDBEAM:
3375 if(!hints)
3376 {
3377 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3378 }
3379 else
3380 {
3381 tempitem=getItemID(itemsbuf,itype_sword,3);
3382
3383 if(tempitem<0) break;
3384
3385 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3386 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3387 {
3388 tempitemx=x;
3389 tempitemy=y;
3390 }
3391
3392 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3393 }
3394
3395 break;
3396
3397 case mfXSWORDBEAM:
3398 if(!hints)
3399 {
3400 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3401 }
3402 else
3403 {
3404 tempitem=getItemID(itemsbuf,itype_sword,4);
3405
3406 if(tempitem<0) break;
3407
3408 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3409 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3410 {
3411 tempitemx=x;
3412 tempitemy=y;
3413 }
3414
3415 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3416 }
3417
3418 break;
3419
3420 case mfHOOKSHOT:
3421 if(!hints)
3422 {
3423 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3424 }
3425 else
3426 {
3427 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3428
3429 if(tempitem<0) break;
3430
3431 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3432 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3433 {
3434 tempitemx=x;
3435 tempitemy=y;
3436 }
3437
3438 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3439 }
3440
3441 break;
3442
3443 case mfWAND:
3444 if(!hints)
3445 {
3446 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3447 }
3448 else
3449 {
3450 tempitem=getItemID(itemsbuf,itype_wand,1);
3451
3452 if(tempitem<0) break;
3453
3454 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3455 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3456 {
3457 tempitemx=x;
3458 tempitemy=y;
3459 }
3460
3461 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3462 }
3463
3464 break;
3465
3466 case mfHAMMER:
3467 if(!hints)
3468 {
3469 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3470 }
3471 else
3472 {
3473 tempitem=getItemID(itemsbuf,itype_hammer,1);
3474
3475 if(tempitem<0) break;
3476
3477 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3478 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3479 {
3480 tempitemx=x;
3481 tempitemy=y;
3482 }
3483
3484 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3485 }
3486
3487 break;
3488
3489 case mfARMOS_ITEM:
3490 case mfDIVE_ITEM:
3491 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3492 {
3493 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3494 }
3495 break;
3496
3497 case 16:
3498 case 17:
3499 case 18:
3500 case 19:
3501 case 20:
3502 case 21:
3503 case 22:
3504 case 23:
3505 case 24:
3506 case 25:
3507 case 26:
3508 case 27:
3509 case 28:
3510 case 29:
3511 case 30:
3512 case 31:
3513 if(!hints)
3514 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3515 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3516
3517 break;
3518 case mfSECRETSNEXT:
3519 if(!hints)
3520 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3521 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3522
3523 break;
3524
3525 case mfSTRIKE:
3526 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3527 {
3528 goto special;
3529 }
3530 else
3531 {
3532 break;
3533 }
3534
3535 default: goto special;
3536
3537 special:
3538 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3539 {
3540 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3541 {
3542 rectfill(dest,x,y,x+15,y+15,WHITE);
3543 }
3544 }
3545
3546 break;
3547 }
3548 }
3549 }
3550
3551 if(layer)
3552 {
3553 if(tmpscr->door[0]==dWALK)
3554 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3555
3556 if(tmpscr->door[1]==dWALK)
3557 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3558
3559 if(tmpscr->door[2]==dWALK)
3560 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3561
3562 if(tmpscr->door[3]==dWALK)
3563 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3564
3565 if(tmpscr->door[0]==dBOMB)
3566 {
3567 showbombeddoor(dest, 0);
3568 }
3569
3570 if(tmpscr->door[1]==dBOMB)
3571 {
3572 showbombeddoor(dest, 1);
3573 }
3574
3575 if(tmpscr->door[2]==dBOMB)
3576 {
3577 showbombeddoor(dest, 2);
3578 }
3579
3580 if(tmpscr->door[3]==dBOMB)
3581 {
3582 showbombeddoor(dest, 3);
3583 }
3584 }
3585
3586 if(tmpscr->stairx + tmpscr->stairy)
3587 {
3588 if(!hints)
3589 {
3590 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3591 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3592 }
3593 else
3594 {
3595 if(tmpscr->flags&fWHISTLE)
3596 {
3597 tempitem=getItemID(itemsbuf,itype_whistle,1);
3598 int32_t tempitemx=-16;
3599 int32_t tempitemy=-16;
3600
3601 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3602 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3603 {
3604 tempitemx=tmpscr->stairx;
3605 tempitemy=tmpscr->stairy+playing_field_offset;
3606 }
3607
3608 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3609 }
3610 }
3611 }
3612 }
3613 }
3614
3615 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3616
3617 void draw_lens_over()
3618 {
3619 // Oh, what the heck.
3620 static BITMAP *lens_scr = NULL;
3621 static int32_t last_width = -1;
3622 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3623
3624 // Only redraw the circle if the size has changed
3625 if(width != last_width)
3626 {
3627 if(lens_scr == NULL)
3628 {
3629 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3630 }
3631
3632 clear_to_color(lens_scr, BLACK);
3633 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3634 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3635 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3636 last_width=width;
3637 }
3638
3639 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3640 }
3641
3642 //----------------------------------------------------------------
3643
3644 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3645 {
3646 //recreating a big bitmap every frame is highly sluggish.
3647 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3648 clear_to_color(wavebuf, BLACK);
3649 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3650
3651 int32_t ofs;
3652 // int32_t amplitude=8;
3653 // int32_t wavelength=4;
3654 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3655 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3656 int32_t amp2=168;
3657 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3658 int32_t i=frame%amp2;
3659
3660 for(int32_t j=0; j<168; j++)
3661 {
3662 if(j&1 && interpol)
3663 {
3664 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3665 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3666 }
3667 else
3668 {
3669 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3670 }
3671
3672 if(ofs)
3673 {
3674 for(int32_t k=0; k<256; k++)
3675 {
3676 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3677 }
3678 }
3679 }
3680 }
3681
3682 void draw_fuzzy(int32_t fuzz)
3683 // draws from right half of scrollbuf to framebuf
3684 {
3685 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3686 byte *start, *si, *di;
3687
3688 if(fuzz<1)
3689 fuzz = 1;
3690
3691 xstep = 128%fuzz;
3692
3693 if(xstep > 0)
3694 xstep = fuzz-xstep;
3695
3696 ystep = 112%fuzz;
3697
3698 if(ystep > 0)
3699 ystep = fuzz-ystep;
3700
3701 firsty = 1;
3702
3703 for(y=0; y<224;)
3704 {
3705 start = &(scrollbuf->line[y][256]);
3706
3707 for(dy=0; dy<ystep && dy+y<224; dy++)
3708 {
3709 si = start;
3710 di = &(framebuf->line[y+dy][0]);
3711 i = xstep;
3712 firstx = 1;
3713
3714 for(dx=0; dx<256; dx++)
3715 {
3716 *(di++) = *si;
3717
3718 if(++i >= fuzz)
3719 {
3720 if(!firstx)
3721 si += fuzz;
3722 else
3723 {
3724 si += fuzz-xstep;
3725 firstx = 0;
3726 }
3727
3728 i = 0;
3729 }
3730 }
3731 }
3732
3733 if(!firsty)
3734 y += fuzz;
3735 else
3736 {
3737 y += ystep;
3738 ystep = fuzz;
3739 firsty = 0;
3740 }
3741 }
3742 }
3743
3744 940368 void updatescr(bool allowwavy)
3745 {
3746
4/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 940357 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
940368 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3747
4/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 940357 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
940368 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3748
3749
1/2
✓ Branch 0 taken 940368 times.
✗ Branch 1 not taken.
940368 if(toogam)
3750 {
3751 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3752 }
3753
3754
1/2
✓ Branch 0 taken 940368 times.
✗ Branch 1 not taken.
940368 if(Showpal)
3755 dump_pal(framebuf);
3756
3757
2/2
✓ Branch 0 taken 933687 times.
✓ Branch 1 taken 6681 times.
940368 if(!Playing)
3758 6681 black_opening_count=0;
3759
3760
2/2
✓ Branch 0 taken 936672 times.
✓ Branch 1 taken 3696 times.
940368 if(black_opening_count<0) //shape is opening up
3761 {
3762 3696 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3763
3764
2/4
✓ Branch 0 taken 3696 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3696 times.
3696 if(Advance||(!Paused))
3765 {
3766 3696 ++black_opening_count;
3767 3696 }
3768 3696 }
3769
2/2
✓ Branch 0 taken 935088 times.
✓ Branch 1 taken 1584 times.
936672 else if(black_opening_count>0) //shape is closing
3770 {
3771 1584 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3772
3773
2/4
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1584 times.
1584 if(Advance||(!Paused))
3774 {
3775 1584 --black_opening_count;
3776 1584 }
3777 1584 }
3778
3779
3/4
✓ Branch 0 taken 935168 times.
✓ Branch 1 taken 5200 times.
✓ Branch 2 taken 935168 times.
✗ Branch 3 not taken.
940368 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3780 {
3781 black_opening_shape = bosCIRCLE;
3782 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3783 refreshTints();
3784 refreshpal=true;
3785 }
3786
3787
2/2
✓ Branch 0 taken 932966 times.
✓ Branch 1 taken 7402 times.
940368 if(refreshpal)
3788 {
3789 7402 refreshpal=false;
3790 7402 RAMpal[253] = _RGB(0,0,0);
3791 7402 RAMpal[254] = _RGB(63,63,63);
3792 7402 hw_palette = &RAMpal;
3793 7402 update_hw_pal = true;
3794
3795 7402 create_rgb_table(&rgb_table, RAMpal, NULL);
3796 7402 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3797 7402 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3798
3799
2/2
✓ Branch 0 taken 1894912 times.
✓ Branch 1 taken 7402 times.
1902314 for(int32_t q=0; q<PAL_SIZE; q++)
3800 {
3801 1894912 trans_table2.data[0][q] = q;
3802 1894912 trans_table2.data[q][q] = q;
3803 1894912 }
3804 7402 }
3805
3806 940368 bool clearwavy = (wavy <= 0);
3807
3808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 940368 times.
940368 if(wavy <= 0)
3809 {
3810 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3811 940368 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3812 940368 }
3813
3814 940368 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3815
3816
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 940368 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
940368 if(wavy && Playing && allowwavy)
3817 {
3818 draw_wavy(framebuf, wavybuf, wavy,false);
3819 }
3820
3821
1/2
✓ Branch 0 taken 940368 times.
✗ Branch 1 not taken.
940368 if(clearwavy)
3822 940368 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3823 else if(Playing && !Paused)
3824 wavy--; // Wavy was set by a script. Decrement it.
3825
3826
5/6
✓ Branch 0 taken 933687 times.
✓ Branch 1 taken 6681 times.
✓ Branch 2 taken 18595 times.
✓ Branch 3 taken 915092 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18595 times.
940368 if(Playing && msgpos && !screenscrolling)
3827 {
3828
1/2
✓ Branch 0 taken 18595 times.
✗ Branch 1 not taken.
18595 if(!(msg_bg_display_buf->clip))
3829 18595 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3830
1/2
✓ Branch 0 taken 18595 times.
✗ Branch 1 not taken.
18595 if(!(msg_portrait_display_buf->clip))
3831 18595 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3832
1/2
✓ Branch 0 taken 18595 times.
✗ Branch 1 not taken.
18595 if(!(msg_txt_display_buf->clip))
3833 18595 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3834 18595 }
3835
3836 /*
3837 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3838 {
3839 BITMAP* subBmp = 0;
3840 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3841 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3842 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3843 destroy_bitmap(subBmp);
3844 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3845 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3846 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3847 }
3848 */
3849
3850
1/2
✓ Branch 0 taken 940368 times.
✗ Branch 1 not taken.
940368 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3851
3852
1/2
✓ Branch 0 taken 940368 times.
✗ Branch 1 not taken.
940368 if(nosubscr)
3853 {
3854 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3855 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3856 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3857 }
3858
3859 //TODO: Optimize blit 'overcalls' -Gleeok
3860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 940368 times.
940368 BITMAP *source = nosubscr ? panorama : wavybuf;
3861 940368 blit(source,framebuf,0,0,0,0,256,224);
3862
3863 940368 update_hw_screen();
3864 940368 }
3865
3866 //----------------------------------------------------------------
3867
3868 PALETTE sys_pal;
3869
3870 int32_t onGUISnapshot()
3871 {
3872 char buf[200];
3873 int32_t num=0;
3874 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3875 do
3876 {
3877 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3878 }
3879 while(num<99999 && exists(buf));
3880
3881 BITMAP *b = create_bitmap_ex(8,resx,resy);
3882
3883 if(b)
3884 {
3885 if(MenuOpen)
3886 {
3887 //Cannot load game's palette while GUI elements are in focus. -Z
3888 //If there is a way to do this, then I have missed it.
3889 /*
3890 game_pal();
3891 RAMpal[253] = _RGB(0,0,0);
3892 RAMpal[254] = _RGB(63,63,63);
3893 set_palette_range(RAMpal,0,255,false);
3894 memcpy(RAMpal, snappal, sizeof(snappal));
3895 create_rgb_table(&rgb_table, RAMpal, NULL);
3896 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3897 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3898
3899 for(int32_t q=0; q<PAL_SIZE; q++)
3900 {
3901 trans_table2.data[0][q] = q;
3902 trans_table2.data[q][q] = q;
3903 }
3904 */
3905 //ringcolor(false);
3906 //get_palette(RAMpal);
3907 blit(screen,b,0,0,0,0,resx,resy);
3908 //al_trace("Menu Open\n");
3909 //game_pal();
3910 //PALETTE temppal;
3911 //get_palette(temppal);
3912 //system_pal();
3913 save_bitmap(buf,b,sys_pal);
3914 //save_bitmap(buf,b,RAMpal);
3915 //save_bitmap(buf,b,snappal);
3916 }
3917 else
3918 {
3919 blit(screen,b,0,0,0,0,resx,resy);
3920 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3921 }
3922 destroy_bitmap(b);
3923 }
3924
3925 return D_O_K;
3926 }
3927
3928 int32_t onNonGUISnapshot()
3929 {
3930 PALETTE temppal;
3931 get_palette(temppal);
3932 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3933
3934 char buf[200];
3935 int32_t num=0;
3936
3937 do
3938 {
3939 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3940 }
3941 while(num<99999 && exists(buf));
3942
3943 BITMAP *panorama = create_bitmap_ex(8,256,168);
3944 /*
3945 PALETTE tempRAMpal;
3946 get_palette(tempRAMpal);
3947
3948 if(tmpscr->flags3&fNOSUBSCR)
3949 {
3950 clear_to_color(panorama,0);
3951 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3952 save_bitmap(buf,panorama,realpal?temppal:tempRAMpal);
3953 }
3954 else
3955 {
3956 save_bitmap(buf,framebuf,realpal?temppal:tempRAMpal);
3957 }
3958
3959 destroy_bitmap(panorama);
3960 return D_O_K;
3961 */
3962 if(tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3963 {
3964 clear_to_color(panorama,0);
3965 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3966 save_bitmap(buf,panorama,realpal?temppal:RAMpal);
3967 }
3968 else
3969 {
3970 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3971 }
3972
3973 destroy_bitmap(panorama);
3974 return D_O_K;
3975 }
3976
3977 int32_t onSnapshot()
3978 {
3979 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3980 {
3981 onGUISnapshot();
3982 }
3983 else
3984 {
3985 onNonGUISnapshot();
3986 }
3987
3988 return D_O_K;
3989 }
3990
3991 int32_t onSaveMapPic()
3992 {
3993 int32_t mapres2 = 0;
3994 char buf[200];
3995 int32_t num=0;
3996 mapscr tmpscr_b[2];
3997 mapscr tmpscr_c[6];
3998 BITMAP* _screen_draw_buffer = NULL;
3999 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4000 set_clip_state(_screen_draw_buffer,1);
4001
4002 for(int32_t i=0; i<6; ++i)
4003 {
4004 tmpscr_c[i] = tmpscr2[i];
4005 tmpscr2[i].zero_memory();
4006
4007 if(i>=2)
4008 {
4009 continue;
4010 }
4011
4012 tmpscr_b[i] = tmpscr[i];
4013 tmpscr[i].zero_memory();
4014 }
4015
4016 do
4017 {
4018 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4019 }
4020 while(num<99999 && exists(buf));
4021
4022 BITMAP* mappic = NULL;
4023
4024
4025 bool done=false, redraw=true;
4026
4027 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4028
4029 if(!mappic)
4030 {
4031 system_pal();
4032 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4033 game_pal();
4034 return D_O_K;;
4035 }
4036
4037 // draw the map
4038 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4039
4040 for(int32_t y=0; y<8; y++)
4041 {
4042 for(int32_t x=0; x<16; x++)
4043 {
4044 if(!displayOnMap(x, y))
4045 {
4046 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4047 }
4048 else
4049 {
4050 int32_t s = (y<<4) + x;
4051 loadscr2(1,s,-1);
4052
4053 for(int32_t i=0; i<6; i++)
4054 {
4055 if(tmpscr[1].layermap[i]<=0)
4056 continue;
4057
4058 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4059 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4060 {
4061 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4062
4063 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4064 }
4065 }
4066
4067 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4068
4069 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4070
4071 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4072 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4073
4074 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4075
4076 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4077 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4078 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4079 {
4080 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4081 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4082 }
4083 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4084
4085 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4086
4087 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4088 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4089 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4090 {
4091 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4092 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4093 }
4094 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4095 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4096
4097 }
4098
4099 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4100 }
4101 }
4102
4103 for(int32_t i=0; i<6; ++i)
4104 {
4105 tmpscr2[i]=tmpscr_c[i];
4106
4107 if(i>=2)
4108 {
4109 continue;
4110 }
4111
4112 tmpscr[i]=tmpscr_b[i];
4113 }
4114
4115 save_bitmap(buf,mappic,RAMpal);
4116 destroy_bitmap(mappic);
4117 destroy_bitmap(_screen_draw_buffer);
4118 return D_O_K;
4119 }
4120
4121 /*
4122 int32_t onSaveMapPic()
4123 {
4124 BITMAP* mappic = NULL;
4125 BITMAP* _screen_draw_buffer = NULL;
4126 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4127 int32_t mapres2 = 0;
4128 char buf[20];
4129 int32_t num=0;
4130 set_clip_state(_screen_draw_buffer,1);
4131 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4132
4133 do
4134 {
4135 sprintf(buf, "zelda%03d.png", ++num);
4136 }
4137 while(num<999 && exists(buf));
4138
4139 // if(!mappic) {
4140 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4141
4142 if(!mappic)
4143 {
4144 system_pal();
4145 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4146 game_pal();
4147 return D_O_K;
4148 }
4149
4150 // }
4151
4152 int32_t layermap, layerscreen;
4153 int32_t x2=0;
4154
4155 // draw the map
4156 for(int32_t y=0; y<8; y++)
4157 {
4158 for(int32_t x=0; x<16; x++)
4159 {
4160 int32_t s = (y<<4) + x;
4161
4162 if(!displayOnMap(x, y))
4163 {
4164 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4165 }
4166 else
4167 {
4168 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4169 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4170
4171 for(int32_t k=0; k<4; k++)
4172 {
4173 if(k==2)
4174 {
4175 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4176 }
4177
4178 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4179
4180 if(layermap>-1)
4181 {
4182 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4183
4184 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4185 {
4186 for(int32_t i=0; i<176; i++)
4187 {
4188 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4189 }
4190 }
4191 else
4192 {
4193 for(int32_t i=0; i<176; i++)
4194 {
4195 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4196 }
4197 }
4198 }
4199 }
4200
4201 for(int32_t i=0; i<176; i++)
4202 {
4203 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4204 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4205 {
4206 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4207 }
4208 }
4209
4210 for(int32_t k=4; k<6; k++)
4211 {
4212 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4213
4214 if(layermap>-1)
4215 {
4216 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4217
4218 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4219 {
4220 for(int32_t i=0; i<176; i++)
4221 {
4222 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4223 }
4224 }
4225 else
4226 {
4227 for(int32_t i=0; i<176; i++)
4228 {
4229 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4230 }
4231 }
4232 }
4233 }
4234 }
4235
4236 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4237 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4238 }
4239
4240 }
4241
4242 save_bitmap(buf,mappic,RAMpal);
4243 destroy_bitmap(mappic);
4244 destroy_bitmap(_screen_draw_buffer);
4245 return D_O_K;
4246 }
4247 */
4248
4249 1 void f_Quit(int32_t type)
4250 {
4251
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(type==qQUIT && !Playing)
4252 return;
4253
4254 1 music_pause();
4255 1 pause_all_sfx();
4256 1 system_pal();
4257 1 clear_keybuf();
4258
4259 1 replay_poll();
4260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (replay_is_replaying())
4261 1 replay_peek_quit();
4262
4263
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!replay_is_replaying())
4264 switch(type)
4265 {
4266 case qQUIT:
4267 onQuit();
4268 break;
4269
4270 case qRESET:
4271 onReset();
4272 break;
4273
4274 case qEXIT:
4275 onExit();
4276 break;
4277 }
4278
4279
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(Quit)
4280 {
4281 1 kill_sfx();
4282 1 music_stop();
4283 1 game_pal();
4284 1 update_hw_screen();
4285 1 }
4286 else
4287 {
4288 game_pal();
4289 music_resume();
4290 resume_all_sfx();
4291 }
4292
4293 1 show_mouse(NULL);
4294 1 eat_buttons();
4295
4296 1 zc_readrawkey(KEY_ESC);
4297
4298 1 zc_readrawkey(KEY_ENTER);
4299 1 }
4300
4301 //----------------------------------------------------------------
4302
4303 int32_t onNoWalls()
4304 {
4305 cheats_enqueue(Cheat::Walls);
4306 return D_O_K;
4307 }
4308
4309 int32_t onIgnoreSideview()
4310 {
4311 cheats_enqueue(Cheat::IgnoreSideView);
4312 return D_O_K;
4313 }
4314
4315 955876 int32_t input_idle(bool checkmouse)
4316 {
4317 static int32_t mx, my, mz, mb;
4318
4319
4/6
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148556 times.
✓ Branch 3 taken 807320 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 148556 times.
1104432 if(keypressed() || zc_key_pressed() ||
4320
4/8
✓ Branch 0 taken 148556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148556 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148556 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 148556 times.
✗ Branch 7 not taken.
148556 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4321 {
4322 807320 idle_count = 0;
4323
4324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 807320 times.
807320 if(active_count < MAX_ACTIVE)
4325 {
4326 807320 ++active_count;
4327 807320 }
4328 807320 }
4329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148556 times.
148556 else if(idle_count < MAX_IDLE)
4330 {
4331 148556 ++idle_count;
4332 148556 active_count = 0;
4333 148556 }
4334
4335 955876 mx = mouse_x;
4336 955876 my = mouse_y;
4337 955876 mz = mouse_z;
4338 955876 mb = mouse_b;
4339
4340 955876 return idle_count;
4341 }
4342
4343 int32_t onGoFast()
4344 {
4345 cheats_enqueue(Cheat::Fast);
4346 return D_O_K;
4347 }
4348
4349 int32_t onKillCheat()
4350 {
4351 cheats_enqueue(Cheat::Kill);
4352 return D_O_K;
4353 }
4354
4355 int32_t onShowLayer0()
4356 {
4357 show_layer_0 = !show_layer_0;
4358 return D_O_K;
4359 }
4360 int32_t onShowLayer1()
4361 {
4362 show_layer_1 = !show_layer_1;
4363 return D_O_K;
4364 }
4365 int32_t onShowLayer2()
4366 {
4367 show_layer_2 = !show_layer_2;
4368 return D_O_K;
4369 }
4370 int32_t onShowLayer3()
4371 {
4372 show_layer_3 = !show_layer_3;
4373 return D_O_K;
4374 }
4375 int32_t onShowLayer4()
4376 {
4377 show_layer_4 = !show_layer_4;
4378 return D_O_K;
4379 }
4380 int32_t onShowLayer5()
4381 {
4382 show_layer_5 = !show_layer_5;
4383 return D_O_K;
4384 }
4385 int32_t onShowLayer6()
4386 {
4387 show_layer_6 = !show_layer_6;
4388 return D_O_K;
4389 }
4390 int32_t onShowLayerO()
4391 {
4392 show_layer_over=!show_layer_over;
4393 return D_O_K;
4394 }
4395 int32_t onShowLayerP()
4396 {
4397 show_layer_push=!show_layer_push;
4398 return D_O_K;
4399 }
4400 int32_t onShowLayerS()
4401 {
4402 show_sprites=!show_sprites;
4403 return D_O_K;
4404 }
4405 int32_t onShowLayerF()
4406 {
4407 show_ffcs=!show_ffcs;
4408 return D_O_K;
4409 }
4410 int32_t onShowLayerW()
4411 {
4412 show_walkflags=!show_walkflags;
4413 return D_O_K;
4414 }
4415 int32_t onShowLayerE()
4416 {
4417 show_effectflags=!show_effectflags;
4418 return D_O_K;
4419 }
4420 int32_t onShowFFScripts()
4421 {
4422 show_ff_scripts=!show_ff_scripts;
4423 return D_O_K;
4424 }
4425 int32_t onShowHitboxes()
4426 {
4427 show_hitboxes=!show_hitboxes;
4428 return D_O_K;
4429 }
4430
4431 int32_t onLightSwitch()
4432 {
4433 cheats_enqueue(Cheat::Light);
4434 return D_O_K;
4435 }
4436
4437 int32_t onGoTo();
4438 int32_t onGoToComplete();
4439
4440 955876 void syskeys()
4441 {
4442 955876 update_system_keys();
4443
4444 int32_t oldtitle_version;
4445
4446
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(close_button_quit)
4447 {
4448 close_button_quit=false;
4449 f_Quit(qEXIT);
4450 }
4451
4452 955876 poll_joystick();
4453
4454
2/10
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 955876 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
955876 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4455 {
4456 oldtitle_version=title_version;
4457 System();
4458 }
4459
4460 955876 mouse_down=gui_mouse_b();
4461
4462
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(zc_read_system_key(KEY_F1))
4463 {
4464 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4465 {
4466 halt=!halt;
4467 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4468 }
4469 else
4470 {
4471 Throttlefps=!Throttlefps;
4472 logic_counter=0;
4473 }
4474 }
4475
4476 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4477 /*
4478 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4479 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4480 */
4481
4482
1/4
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
955876 if(zc_read_system_key(KEY_OPENBRACE)) if(frame_rest_suggest > 0) frame_rest_suggest--;
4483
4484
1/4
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
955876 if(zc_read_system_key(KEY_CLOSEBRACE)) if(frame_rest_suggest <= 2) frame_rest_suggest++;
4485
4486
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(zc_read_system_key(KEY_F2)) ShowFPS=!ShowFPS;
4487
4488
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
955876 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4489
4490
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
955876 if(zc_read_system_key(KEY_F4) && Playing)
4491 {
4492 Paused=true;
4493 Advance=true;
4494 }
4495
4496
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(zc_read_system_key(KEY_F6)) onTryQuit();
4497
4498 #ifndef ALLEGRO_MACOSX
4499 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4500
4501 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4502 #else
4503
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4504
4505
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4506 #endif
4507
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
955876 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4508
4509
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if (zc_read_system_key(KEY_F12))
4510 {
4511 onSnapshot();
4512 }
4513
4514
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
955876 if(debug_enabled && zc_read_system_key(KEY_TAB))
4515 set_debug(!get_debug());
4516
4517
3/4
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 942033 times.
955876 if(get_debug() || cheat>=1)
4518 {
4519
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4520 {
4521 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4522
4523 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4524
4525 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4526
4527 if(zc_readkey(KEY_B))
4528 {
4529 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4530 }
4531
4532 if(zc_readkey(KEY_A))
4533 {
4534 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4535 }
4536 }
4537 13843 }
4538
4539
3/4
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 942033 times.
955876 if(get_debug() || cheat>=2)
4540 {
4541
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4542 {
4543 if(rI())
4544 {
4545 cheats_enqueue(Cheat::Clock);
4546 }
4547 }
4548 13843 }
4549
4550
3/4
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 942033 times.
955876 if(get_debug() || cheat>=4)
4551 {
4552
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4553 {
4554 if(rF11())
4555 {
4556 cheats_enqueue(Cheat::Walls);
4557 }
4558
4559 if(rQ())
4560 {
4561 cheats_enqueue(Cheat::Fast);
4562 }
4563
4564 if(zc_readkey(KEY_F))
4565 {
4566 cheats_enqueue(Cheat::Freeze);
4567 }
4568
4569 if(zc_readkey(KEY_G)) onGoToComplete();
4570
4571 if(zc_readkey(KEY_0)) onShowLayer0();
4572
4573 if(zc_readkey(KEY_1)) onShowLayer1();
4574
4575 if(zc_readkey(KEY_2)) onShowLayer2();
4576
4577 if(zc_readkey(KEY_3)) onShowLayer3();
4578
4579 if(zc_readkey(KEY_4)) onShowLayer4();
4580
4581 if(zc_readkey(KEY_5)) onShowLayer5();
4582
4583 if(zc_readkey(KEY_6)) onShowLayer6();
4584
4585 //if(zc_readkey(KEY_7)) onShowLayerO();
4586 if(zc_readkey(KEY_7)) onShowLayerF();
4587
4588 if(zc_readkey(KEY_8)) onShowLayerS();
4589
4590 if(zc_readkey(KEY_W)) onShowLayerW();
4591
4592 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4593
4594 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4595
4596 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4597 if(zc_readkey(KEY_O)) onShowLayerO();
4598 if(zc_readkey(KEY_P)) onShowLayerP();
4599 if(zc_readkey(KEY_C)) onShowHitboxes();
4600 if(zc_readkey(KEY_F)) onShowFFScripts();
4601 }
4602 13843 }
4603
4604
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(volkeys)
4605 {
4606 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4607
4608 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4609
4610 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4611
4612 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4613 }
4614
4615
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
955876 if(!get_debug() || !SystemKeys || replay_is_replaying())
4616 955876 goto bottom;
4617
4618 if(zc_readkey(KEY_D))
4619 {
4620 details = !details;
4621 rectfill(screen,0,0,319,7,BLACK);
4622 rectfill(screen,0,8,31,239,BLACK);
4623 rectfill(screen,288,8,319,239,BLACK);
4624 rectfill(screen,32,232,287,239,BLACK);
4625 }
4626
4627 if(zc_readkey(KEY_P)) Paused=!Paused;
4628
4629 //if(zc_readkey(KEY_P)) centerHero();
4630 if(zc_readkey(KEY_A))
4631 {
4632 Paused=true;
4633 Advance=true;
4634 }
4635
4636 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4637 #ifndef ALLEGRO_MACOSX
4638 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4639
4640 if(zc_readkey(KEY_F7))
4641 {
4642 Matrix(ss_speed, ss_density, 0);
4643 game_pal();
4644 }
4645 #else
4646 // The reason these are different on Mac in the first place is that
4647 // the OS doesn't let us use F9 and F10...
4648 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4649
4650 if(zc_readkey(KEY_F9))
4651 {
4652 Matrix(ss_speed, ss_density, 0);
4653 game_pal();
4654 }
4655 #endif
4656 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4657 {
4658 //change containers
4659 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4660 {
4661 //magic containers
4662 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4663 {
4664 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4665 }
4666 else
4667 {
4668 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4669 }
4670 }
4671 else
4672 {
4673 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4674 {
4675 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4676 }
4677 else
4678 {
4679 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4680 }
4681 }
4682 }
4683
4684 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4685 {
4686 //change containers
4687 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4688 {
4689 //magic containers
4690 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4691 {
4692 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4693 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4694 //heart containers
4695 }
4696 else
4697 {
4698 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4699 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4700 }
4701 }
4702 else
4703 {
4704 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4705 {
4706 game->set_magic(zc_max(game->get_magic()-1,0));
4707 }
4708 else
4709 {
4710 game->set_life(zc_max(game->get_life()-1,0));
4711 }
4712 }
4713 }
4714
4715 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4716
4717 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4718
4719 verifyBothWeapons();
4720
4721 bottom:
4722
4723
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(input_idle(true) > after_time())
4724 {
4725 Matrix(ss_speed, ss_density, 0);
4726 game_pal();
4727 }
4728 //Saffith's method of separating system and game key bindings. Can't do this!!
4729 //restoreInput(); //This caused input to become randomly 'stuck'. -Z
4730
4731 //while(Playing && keypressed())
4732 //readkey();
4733 // What's the Playing check for?
4734 955876 clear_keybuf();
4735 955876 }
4736
4737 62414 void checkQuitKeys()
4738 {
4739 #ifndef ALLEGRO_MACOSX
4740 if(zc_readrawkey(KEY_F9)) f_Quit(qRESET);
4741
4742 if(zc_readrawkey(KEY_F10)) f_Quit(qEXIT);
4743 #else
4744
1/2
✓ Branch 0 taken 62414 times.
✗ Branch 1 not taken.
62414 if(zc_readrawkey(KEY_F7)) f_Quit(qRESET);
4745
4746
1/2
✓ Branch 0 taken 62414 times.
✗ Branch 1 not taken.
62414 if(zc_readrawkey(KEY_F8)) f_Quit(qEXIT);
4747 #endif
4748 62414 }
4749
4750 41529 bool CheatModifierKeys()
4751 {
4752 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4753 // to trigger cheats.
4754
1/2
✓ Branch 0 taken 41529 times.
✗ Branch 1 not taken.
41529 if (replay_is_replaying())
4755 41529 return false;
4756
4757 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4758 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4759 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4760 {
4761 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4762 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4763 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4764 {
4765 return true;
4766 }
4767 }
4768 return false;
4769 41529 }
4770
4771 //99:05:54, for some reason?
4772 #define OLDMAXTIME 21405240
4773 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4774 #define MAXTIME 1944000000
4775
4776 940377 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4777 {
4778
2/2
✓ Branch 0 taken 703445 times.
✓ Branch 1 taken 236932 times.
940377 if(zcmusic!=NULL)
4779 {
4780 236932 zcmusic_poll();
4781 236932 }
4782
4783
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 940377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 940377 times.
940377 while(Paused && !Advance && !Quit)
4784 {
4785 // have to call this, otherwise we'll get an infinite loop
4786 syskeys();
4787 if(allowF6Script)
4788 {
4789 FFCore.runF6Engine();
4790 }
4791 if (replay_get_mode() != ReplayMode::Assert)
4792 updatescr(allowwavy);
4793 throttleFPS();
4794
4795 #ifdef _WIN32
4796
4797 if(use_dwm_flush)
4798 {
4799 do_DwmFlush();
4800 }
4801
4802 #endif
4803
4804 // to keep music playing
4805 if(zcmusic!=NULL)
4806 {
4807 zcmusic_poll();
4808 }
4809 }
4810
4811
2/2
✓ Branch 0 taken 940369 times.
✓ Branch 1 taken 8 times.
940377 if(Quit)
4812 8 return;
4813
4814
3/4
✓ Branch 0 taken 933688 times.
✓ Branch 1 taken 6681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 933688 times.
940369 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4815 933688 game->change_time(1);
4816
4817 940369 Advance=false;
4818
4819
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 940368 times.
940369 if (replay_is_active())
4820 {
4821
2/2
✓ Branch 0 taken 655663 times.
✓ Branch 1 taken 284705 times.
940368 if (replay_get_version() >= 3)
4822 284705 replay_poll();
4823
2/2
✓ Branch 0 taken 929615 times.
✓ Branch 1 taken 10753 times.
940368 if (replay_get_version() >= 6)
4824 10753 replay_peek_input();
4825 940368 }
4826 940369 update_keys();
4827
4828 940369 ++frame;
4829
4830
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 940368 times.
940369 if (replay_is_replaying())
4831 940368 replay_do_cheats();
4832 940369 syskeys();
4833
4834 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4835 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4836 // approach here means it doesn't matter which call adds the cheat.
4837 940369 cheats_execute_queued();
4838
4839
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 940368 times.
940369 if (replay_is_replaying())
4840 940368 replay_peek_quit();
4841
2/2
✓ Branch 0 taken 940368 times.
✓ Branch 1 taken 1 times.
940369 if (GameFlags & GAMEFLAG_TRYQUIT)
4842 1 replay_step_quit(0);
4843
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 940368 times.
940369 if(allowF6Script)
4844 {
4845 940368 FFCore.runF6Engine();
4846 940368 }
4847
2/2
✓ Branch 0 taken 940336 times.
✓ Branch 1 taken 33 times.
940369 if (Quit)
4848 33 replay_step_quit(Quit);
4849 // Someday... maybe install a Turbo button here?
4850 940369 updatescr(allowwavy);
4851 940369 throttleFPS();
4852
4853 #ifdef _WIN32
4854
4855 if(use_dwm_flush)
4856 {
4857 do_DwmFlush();
4858 }
4859
4860 #endif
4861
4862 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4863
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 940072 times.
940369 if(sfxcleanup)
4864 940072 sfx_cleanup();
4865 940377 }
4866
4867 void zapout()
4868 {
4869 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4870 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4871
4872 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4873 script_drawing_commands.Clear();
4874
4875 // zap out
4876 for(int32_t i=1; i<=24; i++)
4877 {
4878 draw_fuzzy(i);
4879 syskeys();
4880 advanceframe(true);
4881
4882 if(Quit)
4883 {
4884 break;
4885 }
4886 }
4887 }
4888
4889 void zapin()
4890 {
4891 FFCore.warpScriptCheck();
4892 draw_screen(tmpscr);
4893 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4894 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4895 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4896
4897 // zap out
4898 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4899 for(int32_t i=24; i>=1; i--)
4900 {
4901 draw_fuzzy(i);
4902 syskeys();
4903 advanceframe(true);
4904
4905 if(Quit)
4906 {
4907 break;
4908 }
4909 }
4910 }
4911
4912
4913 void wavyout(bool showhero)
4914 {
4915 draw_screen(tmpscr, showhero);
4916 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4917
4918 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4919 clear_to_color(wavebuf,0);
4920 blit(framebuf,wavebuf,0,0,16,0,256,224);
4921
4922 static PALETTE wavepal;
4923
4924 int32_t ofs;
4925 int32_t amplitude=8;
4926
4927 int32_t wavelength=4;
4928 double palpos=0, palstep=4, palstop=126;
4929
4930 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4931 for(int32_t i=0; i<168; i+=wavelength)
4932 {
4933 for(int32_t l=0; l<256; l++)
4934 {
4935 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4936 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4937 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4938 }
4939
4940 palpos+=palstep;
4941
4942 if(palpos>=0)
4943 {
4944 hw_palette = &wavepal;
4945 update_hw_pal = true;
4946 }
4947 else
4948 {
4949 hw_palette = &RAMpal;
4950 update_hw_pal = true;
4951 }
4952
4953 for(int32_t j=0; j+playing_field_offset<224; j++)
4954 {
4955 for(int32_t k=0; k<256; k++)
4956 {
4957 ofs=0;
4958
4959 if((j<i)&&(j&1))
4960 {
4961 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4962 }
4963
4964 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4965 }
4966 }
4967
4968 syskeys();
4969 advanceframe(true);
4970
4971 // animate_combos();
4972 if(Quit)
4973 break;
4974 }
4975
4976 destroy_bitmap(wavebuf);
4977 }
4978
4979 void wavyin()
4980 {
4981 draw_screen(tmpscr);
4982 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4983
4984 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4985 clear_to_color(wavebuf,0);
4986 blit(framebuf,wavebuf,0,0,16,0,256,224);
4987
4988 static PALETTE wavepal;
4989
4990 //Breaks dark rooms.
4991 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4992 /*
4993 loadfullpal();
4994 loadlvlpal(DMaps[currdmap].color);
4995 ringcolor(false);
4996 */
4997 refreshpal=false;
4998 int32_t ofs;
4999 int32_t amplitude=8;
5000 int32_t wavelength=4;
5001 double palpos=168, palstep=4, palstop=126;
5002
5003 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
5004 for(int32_t i=0; i<168; i+=wavelength)
5005 {
5006 for(int32_t l=0; l<256; l++)
5007 {
5008 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
5009 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
5010 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
5011 }
5012
5013 palpos-=palstep;
5014
5015 if(palpos>=0)
5016 {
5017 hw_palette = &wavepal;
5018 update_hw_pal = true;
5019 }
5020 else
5021 {
5022 hw_palette = &RAMpal;
5023 update_hw_pal = true;
5024 }
5025
5026 for(int32_t j=0; j+playing_field_offset<224; j++)
5027 {
5028 for(int32_t k=0; k<256; k++)
5029 {
5030 ofs=0;
5031
5032 if((j<(167-i))&&(j&1))
5033 {
5034 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
5035 }
5036
5037 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
5038 }
5039 }
5040
5041 syskeys();
5042 advanceframe(true);
5043 // animate_combos();
5044
5045 if(Quit)
5046 break;
5047 }
5048
5049 destroy_bitmap(wavebuf);
5050 }
5051
5052 284 void blackscr(int32_t fcnt,bool showsubscr)
5053 {
5054 284 reset_pal_cycling();
5055 284 script_drawing_commands.Clear();
5056
5057 284 FFCore.warpScriptCheck();
5058 284 bool showtime = game->should_show_time();
5059
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 8520 times.
8804 while(fcnt>0)
5060 {
5061 8520 clear_bitmap(framebuf);
5062
5063
2/2
✓ Branch 0 taken 2340 times.
✓ Branch 1 taken 6180 times.
8520 if(showsubscr)
5064 {
5065 6180 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5066
3/4
✓ Branch 0 taken 6180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 6150 times.
6180 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5067 {
5068 30 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5069 30 }
5070 6180 }
5071
5072 8520 syskeys();
5073 8520 advanceframe(true);
5074
5075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8520 times.
8520 if(Quit)
5076 break;
5077
5078 8520 --fcnt;
5079 }
5080 284 }
5081
5082 94 void openscreen(int32_t shape)
5083 {
5084 94 reset_pal_cycling();
5085 94 black_opening_count=0;
5086
5087
3/4
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 56 times.
94 if(COOLSCROLL || shape>-1)
5088 {
5089 38 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5090 38 return;
5091 }
5092 else
5093 {
5094 56 Hero.setDontDraw(true);
5095 56 show_subscreen_dmap_dots=false;
5096 56 show_subscreen_numbers=false;
5097 // show_subscreen_items=false;
5098 56 show_subscreen_life=false;
5099 }
5100
5101 56 int32_t x=128;
5102
5103 56 FFCore.warpScriptCheck();
5104
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 4480 times.
4536 for(int32_t i=0; i<80; i++)
5105 {
5106 4480 draw_screen(tmpscr);
5107 //? draw_screen already draws the subscreen -DD
5108 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5109 4480 x=128-(((i*128/80)/8)*8);
5110
5111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4480 times.
4480 if(x>0)
5112 {
5113 4480 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5114 4480 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5115 4480 }
5116
5117 // x=((80-i)/2)*4;
5118 /*
5119 --x;
5120 switch(++c)
5121 {
5122 case 5: c=0;
5123 case 0:
5124 case 2:
5125 case 3: --x; break;
5126 }
5127 */
5128 4480 syskeys();
5129 4480 advanceframe(true);
5130
5131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4480 times.
4480 if(Quit)
5132 {
5133 break;
5134 }
5135 4480 }
5136
5137 56 Hero.setDontDraw(false);
5138 56 show_subscreen_items=true;
5139 56 show_subscreen_dmap_dots=true;
5140 94 }
5141
5142 void closescreen(int32_t shape)
5143 {
5144 reset_pal_cycling();
5145 black_opening_count=0;
5146
5147 if(COOLSCROLL || shape>-1)
5148 {
5149 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5150 return;
5151 }
5152 else
5153 {
5154 Hero.setDontDraw(true);
5155 show_subscreen_dmap_dots=false;
5156 show_subscreen_numbers=false;
5157 // show_subscreen_items=false;
5158 show_subscreen_life=false;
5159 }
5160
5161 int32_t x=128;
5162
5163 FFCore.warpScriptCheck();
5164 for(int32_t i=79; i>=0; --i)
5165 {
5166 draw_screen(tmpscr);
5167 //? draw_screen already draws the subscreen -DD
5168 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5169 x=128-(((i*128/80)/8)*8);
5170
5171 if(x>0)
5172 {
5173 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5174 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5175 }
5176
5177 // x=((80-i)/2)*4;
5178 /*
5179 --x;
5180 switch(++c)
5181 {
5182 case 5: c=0;
5183 case 0:
5184 case 2:
5185 case 3: --x; break;
5186 }
5187 */
5188 syskeys();
5189 advanceframe(true);
5190
5191 if(Quit)
5192 {
5193 break;
5194 }
5195 }
5196
5197 Hero.setDontDraw(false);
5198 show_subscreen_items=true;
5199 show_subscreen_dmap_dots=true;
5200 }
5201
5202 4 int32_t TriforceCount()
5203 {
5204 4 int32_t c=0;
5205
5206
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4 times.
36 for(int32_t i=1; i<=8; i++)
5207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
64 if(game->lvlitems[i]&liTRIFORCE)
5208 32 ++c;
5209
5210 4 return c;
5211 }
5212
5213 int32_t onCustomGame()
5214 {
5215 int32_t file = getsaveslot();
5216
5217 if(file < 0)
5218 return D_O_K;
5219
5220 bool ret = (custom_game(file)!=0);
5221 return ret ? D_CLOSE : D_O_K;
5222 }
5223
5224 int32_t onContinue()
5225 {
5226 return D_CLOSE;
5227 }
5228
5229 int32_t onEsc() // Unused?? -L
5230 {
5231 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5232 }
5233
5234 int32_t onVsync()
5235 {
5236 Throttlefps = !Throttlefps;
5237 save_game_configs();
5238 return D_O_K;
5239 }
5240
5241 int32_t onWinPosSave()
5242 {
5243 SaveWinPos = !SaveWinPos;
5244 return D_O_K;
5245 }
5246
5247 int32_t onClickToFreeze()
5248 {
5249 ClickToFreeze = !ClickToFreeze;
5250 save_game_configs();
5251 return D_O_K;
5252 }
5253
5254 int32_t OnSaveZCConfig()
5255 {
5256 if(jwin_alert3(
5257 "Save Configuration",
5258 "Are you sure that you wish to save your present configuration settings?",
5259 "This will overwrite your prior settings!",
5260 NULL,
5261 "&Yes",
5262 "&No",
5263 NULL,
5264 'y',
5265 'n',
5266 0,
5267 lfont) == 1)
5268 {
5269 save_game_configs();
5270 return D_O_K;
5271 }
5272 else return D_O_K;
5273 }
5274
5275 int32_t OnnClearQuestDir()
5276 {
5277 if(jwin_alert3(
5278 "Clear Current Directory Cache",
5279 "Are you sure that you wish to clear the current cached directory?",
5280 "This will default the current directory to the ROOT for this instance of ZC Player!",
5281 NULL,
5282 "&Yes",
5283 "&No",
5284 NULL,
5285 'y',
5286 'n',
5287 0,
5288 lfont) == 1)
5289 {
5290 set_config_string("zeldadx","win_qst_dir","");
5291 flush_config_file();
5292 strcpy(qstdir,get_config_string("zeldadx","win_qst_dir",""));
5293 //strcpy(filepath,get_config_string("zeldadx","win_qst_dir",""));
5294 save_game_configs();
5295 #ifdef __EMSCRIPTEN__
5296 em_sync_fs();
5297 #endif
5298 return D_O_K;
5299 }
5300 else return D_O_K;
5301 }
5302
5303
5304 int32_t onConsoleZASM()
5305 {
5306 if ( !zasm_debugger )
5307 {
5308 AlertDialog("WARNING: ZASM Debugger",
5309 "Enabling this will open the ZASM Debugger Console"
5310 "\nThis will likely grind ZC to a halt with lag."
5311 "\nTo make any use of this, it is suggested that you read"
5312 "\nthe documentation for 'void Breakpoint(char[] string);'"
5313 " in 'ZScript_Additions.txt'"
5314 "\nThis is not recommended for normal users,"
5315 " and is only intended for ZC developers,"
5316 "\nor quest developers coding directly in ZASM"
5317 "\nAre you sure that you wish to open the ZASM Debugger?",
5318 [&](bool ret,bool)
5319 {
5320 if(ret)
5321 {
5322 FFCore.ZASMPrint(true);
5323 zasm_debugger = 1;
5324 save_game_configs();
5325 }
5326 }).show();
5327 return D_O_K;
5328 }
5329 else
5330 {
5331 zasm_debugger = 0;
5332 save_game_configs();
5333 FFCore.ZASMPrint(false);
5334 return D_O_K;
5335 }
5336 }
5337
5338
5339 int32_t onConsoleZScript()
5340 {
5341 if ( !zscript_debugger )
5342 {
5343 AlertDialog("ZScript Debugger",
5344 "Enabling this will open the ZScript Debugger Console"
5345 "\nThis will display any messages logged by scripts,"
5346 " including script errors."
5347 "\nAre you sure that you wish to open the ZScript Debugger?",
5348 [&](bool ret,bool)
5349 {
5350 if(ret)
5351 {
5352 FFCore.ZScriptConsole(true);
5353 zscript_debugger = 1;
5354 save_game_configs();
5355 }
5356 }).show();
5357 return D_O_K;
5358 }
5359 else
5360 {
5361 zscript_debugger = 0;
5362 save_game_configs();
5363 FFCore.ZScriptConsole(false);
5364 return D_O_K;
5365 }
5366 }
5367
5368
5369 int32_t onFrameSkip()
5370 {
5371 FrameSkip = !FrameSkip;
5372 return D_O_K;
5373 }
5374
5375 int32_t onSaveDragResize()
5376 {
5377 SaveDragResize = !SaveDragResize;
5378 return D_O_K;
5379 }
5380
5381 int32_t onDragAspect()
5382 {
5383 DragAspect = !DragAspect;
5384 return D_O_K;
5385 }
5386
5387 int32_t onTransLayers()
5388 {
5389 TransLayers = !TransLayers;
5390 save_game_configs();
5391 return D_O_K;
5392 }
5393
5394 int32_t onNESquit()
5395 {
5396 NESquit = !NESquit;
5397 save_game_configs();
5398 return D_O_K;
5399 }
5400
5401 int32_t onVolKeys()
5402 {
5403 volkeys = !volkeys;
5404 save_game_configs();
5405 return D_O_K;
5406 }
5407
5408 int32_t onShowFPS()
5409 {
5410 ShowFPS = !ShowFPS;
5411 save_game_configs();
5412 return D_O_K;
5413 }
5414
5415 112793368 bool is_Fkey(int32_t k)
5416 {
5417
2/2
✓ Branch 0 taken 11470512 times.
✓ Branch 1 taken 101322856 times.
112793368 switch(k)
5418 {
5419 case KEY_F1:
5420 case KEY_F2:
5421 case KEY_F3:
5422 case KEY_F4:
5423 case KEY_F5:
5424 case KEY_F6:
5425 case KEY_F7:
5426 case KEY_F8:
5427 case KEY_F9:
5428 case KEY_F10:
5429 case KEY_F11:
5430 case KEY_F12:
5431 11470512 return true;
5432 }
5433
5434 101322856 return false;
5435 112793368 }
5436
5437 void kb_getkey(DIALOG *d)
5438 {
5439 d->flags|=D_SELECTED;
5440
5441 scare_mouse();
5442 jwin_button_proc(MSG_DRAW,d,0);
5443 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5444 // text_mode(vc(11));
5445 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5446 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5447 unscare_mouse();
5448
5449 update_hw_screen(true);
5450
5451 clear_keybuf();
5452 int32_t k = next_press_key();
5453 clear_keybuf();
5454
5455 //shnarf
5456 //47=f1
5457 //59=esc
5458 if(k>0 && k<123 && !((k>46)&&(k<60)))
5459 *((int32_t*)d->dp3) = k;
5460
5461
5462 d->flags&=~D_SELECTED;
5463 }
5464
5465
5466 //Used by all keyboard key settings dialogues.
5467 void kb_clearjoystick(DIALOG *d)
5468 {
5469 d->flags|=D_SELECTED;
5470
5471 scare_mouse();
5472 jwin_button_proc(MSG_DRAW,d,0);
5473 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5474 // text_mode(vc(11));
5475 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5476 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5477 unscare_mouse();
5478
5479 update_hw_screen(true);
5480
5481 clear_keybuf();
5482 int32_t k = next_press_key();
5483 clear_keybuf();
5484
5485 //shnarf
5486 //47=f1
5487 //59=esc
5488 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5489 // *((int32_t*)d->dp3) = k;
5490 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5491
5492
5493 d->flags&=~D_SELECTED;
5494 }
5495
5496 //Clears key to 0.
5497 //Used by all keyboard key settings dialogues.
5498 void kb_clearkey(DIALOG *d)
5499 {
5500 d->flags|=D_SELECTED;
5501
5502 scare_mouse();
5503 jwin_button_proc(MSG_DRAW,d,0);
5504 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5505 // text_mode(vc(11));
5506 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5507 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5508 unscare_mouse();
5509
5510 update_hw_screen(true);
5511
5512 clear_keybuf();
5513 int32_t k = next_press_key();
5514 clear_keybuf();
5515
5516 //shnarf
5517 //47=f1
5518 //59=esc
5519 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5520 // *((int32_t*)d->dp3) = k;
5521 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5522
5523
5524 d->flags&=~D_SELECTED;
5525 }
5526
5527
5528 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5529 {
5530 switch(msg)
5531 {
5532 case MSG_KEY:
5533 case MSG_CLICK:
5534
5535 kb_clearjoystick(d);
5536
5537 while(gui_mouse_b())
5538 {
5539 clear_keybuf();
5540 rest(1);
5541 }
5542
5543 return D_REDRAW;
5544 }
5545
5546 return jwin_button_proc(msg,d,c);
5547 }
5548
5549 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5550 {
5551 switch(msg)
5552 {
5553 case MSG_KEY:
5554 case MSG_CLICK:
5555
5556 kb_getkey(d);
5557
5558 while(gui_mouse_b()) {
5559 clear_keybuf();
5560 rest(1);
5561 }
5562
5563 return D_REDRAW;
5564 }
5565
5566 return jwin_button_proc(msg,d,c);
5567 }
5568
5569 //Only used in keyboard settings dialogues to clear keys.
5570 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5571 {
5572 switch(msg)
5573 {
5574 case MSG_KEY:
5575 case MSG_CLICK:
5576
5577 kb_clearkey(d);
5578
5579 while(gui_mouse_b()) {
5580 clear_keybuf();
5581 rest(1);
5582 }
5583
5584 return D_REDRAW;
5585 }
5586
5587 return jwin_button_proc(msg,d,c);
5588 }
5589
5590 void j_getbtn(DIALOG *d)
5591 {
5592 d->flags|=D_SELECTED;
5593 scare_mouse();
5594 jwin_button_proc(MSG_DRAW,d,0);
5595 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5596 // text_mode(vc(11));
5597 int32_t y = gui_bmp->h/2 - 12;
5598 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5599 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5600 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5601 unscare_mouse();
5602
5603 update_hw_screen(true);
5604
5605 int32_t b = next_press_btn();
5606
5607 if(b>=0)
5608 *((int32_t*)d->dp3) = b;
5609
5610 d->flags&=~D_SELECTED;
5611
5612 if (player)
5613 player->joy_on = TRUE;
5614 }
5615
5616 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5617 {
5618 switch(msg)
5619 {
5620 case MSG_KEY:
5621 case MSG_CLICK:
5622
5623 j_getbtn(d);
5624
5625 while(gui_mouse_b()) {
5626 rest(1);
5627 clear_keybuf();
5628 }
5629
5630 return D_REDRAW;
5631 }
5632
5633 return jwin_button_proc(msg,d,c);
5634 }
5635
5636 //shnarf
5637 const char *key_str[] =
5638 {
5639 "(none) ", "a ", "b ", "c ",
5640 "d ", "e ", "f ", "g ",
5641 "h ", "i ", "j ", "k ",
5642 "l ", "m ", "n ", "o ",
5643 "p ", "q ", "r ", "s ",
5644 "t ", "u ", "v ", "w ",
5645 "x ", "y ", "z ", "0 ",
5646 "1 ", "2 ", "3 ", "4 ",
5647 "5 ", "6 ", "7 ", "8 ",
5648 "9 ", "num 0 ", "num 1 ", "num 2 ",
5649 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5650 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5651 "f2 ", "f3 ", "f4 ", "f5 ",
5652 "f6 ", "f7 ", "f8 ", "f9 ",
5653 "f10 ", "f11 ", "f12 ", "esc ",
5654 "~ ", "- ", "= ", "backspace ",
5655 "tab ", "{ ", "} ", "enter ",
5656 ": ", "quote ", "\\ ", "\\ (2) ",
5657 ", ", ". ", "/ ", "space ",
5658 "insert ", "delete ", "home ", "end ",
5659 "page up ", "page down ", "left ", "right ",
5660 "up ", "down ", "num / ", "num * ",
5661 "num - ", "num + ", "num delete ", "num enter ",
5662 "print screen ", "pause ", "abnt c1 ", "yen ",
5663 "kana ", "convert ", "no convert ", "at ",
5664 "circumflex ", ": (2) ", "kanji ", "num = ",
5665 "back quote ", "; ", "command ", "unknown (0) ",
5666 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5667 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5668 "right shift ", "left control ", "right control", "alt ",
5669 "alt gr ", "left win ", "right win ", "menu ",
5670 "scroll lock ", "number lock ", "caps lock ", "MAX"
5671 };
5672
5673
5674 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5675 //extern int32_t zcmusic_bufsz;
5676
5677 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5678 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5679
5680 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5681 {
5682 //these are here to bypass compiler warnings about unused arguments
5683 c=c;
5684
5685 if(msg==MSG_DRAW)
5686 {
5687 switch(d->w)
5688 {
5689 case 0:
5690 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5691 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5692 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5693 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5694 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5695 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5696 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5697 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5698 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5699 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5700 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5701 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5702 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5703 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5704 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5705 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5706 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5707 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5708 break;
5709
5710 case 1:
5711 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5712 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5713 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5714 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5715 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5716 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5717 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5718 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5719 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5720 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5721 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5722 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5723 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5724 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5725 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5726 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5727 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5728 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5729 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5730 break;
5731
5732 case 2:
5733 sprintf(str_a,"%3d",midi_volume);
5734 sprintf(str_b,"%3d",digi_volume);
5735 sprintf(str_l,"%3d",emusic_volume);
5736 sprintf(str_m,"%3dKB",zcmusic_bufsz);
5737 sprintf(str_r,"%3d",sfx_volume);
5738 strcpy(str_s,pan_str[pan_style]);
5739 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5740 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5741 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5742 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5743 break;
5744 }
5745 }
5746
5747 return D_O_K;
5748 }
5749
5750 int32_t set_vol(void *dp3, int32_t d2)
5751 {
5752 switch(((int32_t*)dp3)[0])
5753 {
5754 case 0:
5755 midi_volume = zc_min(d2<<3,255);
5756 break;
5757
5758 case 1:
5759 digi_volume = zc_min(d2<<3,255);
5760 break;
5761
5762 case 2:
5763 emusic_volume = zc_min(d2<<3,255);
5764 break;
5765
5766 case 3:
5767 sfx_volume = zc_min(d2<<3,255);
5768 break;
5769 }
5770
5771 scare_mouse();
5772 // text_mode(vc(11));
5773 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5774 unscare_mouse();
5775 return D_O_K;
5776 }
5777
5778 int32_t set_pan(void *dp3, int32_t d2)
5779 {
5780 pan_style = vbound(d2,0,3);
5781 scare_mouse();
5782 // text_mode(vc(11));
5783 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5784 unscare_mouse();
5785 return D_O_K;
5786 }
5787
5788 int32_t set_buf(void *dp3, int32_t d2)
5789 {
5790 scare_mouse();
5791 // text_mode(vc(11));
5792 zcmusic_bufsz = d2 + 1;
5793 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5794 unscare_mouse();
5795 return D_O_K;
5796 }
5797
5798 static int32_t gamepad_btn_list[] =
5799 {
5800 6,
5801 7,8,9,10,11,12,13,14,15,16,17,
5802 18,19,20,21,22,23,24,25,26,27,28,
5803 29,30,31,32,33,34,35,36,37,38,39,
5804 -1
5805 };
5806
5807 static int32_t gamepad_dirs_list[] =
5808 {
5809 40,41,42,43,
5810 44,45,46,47,
5811 48,49,50,51,
5812 52,53,54,55,
5813 56,
5814 -1
5815 };
5816
5817 static TABPANEL gamepad_tabs[] =
5818 {
5819 // (text)
5820 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5821 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5822 { NULL, 0, NULL, 0, NULL }
5823 };
5824
5825 static DIALOG gamepad_dlg[] =
5826 {
5827 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5828 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5829 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5830 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5831 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5832 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5833 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5834 // 6
5835 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5836 // 7
5837 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5838 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5839 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5840 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5841 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5842 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5843 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5844 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5845 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5846 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5847 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5848 // 18
5849 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5850 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5851 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5852 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5853 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5854 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5855 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5856 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5857 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5858 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5859 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5860 // 29
5861 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5862 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5863 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5864 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5865 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5866 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5867 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5868 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5869 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5870 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5871 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5872 // 40
5873 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5874 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5875 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5876 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5877 // 44
5878 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5879 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5880 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5881 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5882 // 48
5883 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5884 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5885 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5886 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5887 // 52
5888 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5889 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5890 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5891 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5892 // 56
5893 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5894 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5895 };
5896
5897 static int32_t keyboard_keys_list[] =
5898 {
5899 6,7,8,9,10,
5900 11,12,13,14,15,16,17,18,19,20,
5901 21,22,23,24,25,26,27,28,29,30,
5902 31,32,33,34,35,36,37,38,39,40,
5903 -1
5904 };
5905
5906 static int32_t keyboard_dirs_list[] =
5907 {
5908 41,42,43,44,
5909 45,46,47,48,
5910 49,50,51,52,
5911 53,54,55,56,
5912 -1
5913 };
5914
5915 static int32_t keyboard_mods_list[] =
5916 {
5917 57,58,59,60,
5918 61,62,63,64,
5919 65,66,67,68,
5920 69,70,71,72,
5921 -1
5922 };
5923
5924 static TABPANEL keyboard_control_tabs[] =
5925 {
5926 // (text)
5927 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5928 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5929 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5930 { NULL, 0, NULL, 0, NULL }
5931 };
5932
5933 static DIALOG keyboard_control_dlg[] =
5934 {
5935 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5936 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5937 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5938 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5939 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5940 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5941 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5942 // Keys
5943 // 6
5944 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5945 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5946 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5947 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5948 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5949 // 11
5950 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5951 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5952 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5953 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5954 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5955 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5956 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5957 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5958 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5959 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5960 // 21
5961 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5962 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5963 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5964 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5965 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5966 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5967 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5968 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5969 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5970 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5971 // 31
5972 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5973 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5974 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5975 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5976 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5977 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5978 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5979 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5980 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5981 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5982 // Dirs
5983 // 41
5984 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5985 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5986 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5987 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5988 // 45
5989 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5990 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5991 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5992 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5993 // 49
5994 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5995 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5996 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5997 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5998 // 53
5999 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
6000 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
6001 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
6002 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
6003 // Mods
6004 // 57
6005 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6006 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6007 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
6008 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
6009 // 61
6010 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
6011 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
6012 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
6013 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
6014 // 65
6015 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
6016 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
6017 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
6018 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
6019 // 69
6020 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
6021 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
6022 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
6023 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
6024 // 73
6025 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6026 };
6027
6028 /*
6029 int32_t midi_dp[3] = {0,147,104};
6030 int32_t digi_dp[3] = {1,147,120};
6031 int32_t pan_dp[3] = {0,147,136};
6032 int32_t buf_dp[3] = {0,147,152};
6033 */
6034 int32_t midi_dp[3] = {0,0,0};
6035 int32_t digi_dp[3] = {1,0,0};
6036 int32_t emus_dp[3] = {2,0,0};
6037 int32_t buf_dp[3] = {0,0,0};
6038 int32_t sfx_dp[3] = {3,0,0};
6039 int32_t pan_dp[3] = {0,0,0};
6040
6041 static DIALOG sound_dlg[] =
6042 {
6043 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
6044 11 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
6045 11 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6046 11 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6047 11 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6048 11 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6049 11 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6050 11 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
6051 11 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
6052 11 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
6053 11 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
6054 // 10
6055 11 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
6056 11 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
6057 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6058 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6059 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6060 11 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
6061 11 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
6062 11 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
6063 11 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
6064 11 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
6065 //20
6066 11 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
6067 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6068 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6069 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6070 11 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
6071 11 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
6072 11 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
6073 11 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
6074 11 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
6075 11 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
6076 //30
6077 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6078 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6079 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6080 11 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6081 };
6082
6083 char zc_builddate[80];
6084 char zc_aboutstr[80];
6085
6086 static DIALOG about_dlg[] =
6087 {
6088 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6089 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
6090 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6091 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
6092 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6093 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
6094 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
6095 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
6096 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
6097 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
6098 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6099 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6100 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6101 };
6102
6103
6104 static DIALOG quest_dlg[] =
6105 {
6106 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6107 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6108 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6109 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6110 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6111 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6112 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, QHeader.version, NULL, NULL },
6113 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6114 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6115 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6116 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6117 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6118 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6119 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6120 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6121 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6122 };
6123
6124 static DIALOG triforce_dlg[] =
6125 {
6126 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6127 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6128 // 1
6129 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6130 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6131 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6132 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6133 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6134 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6135 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6136 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6137 // 9
6138 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6139 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6140 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6141 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6142 };
6143
6144 /*static DIALOG equip_dlg[] =
6145 {
6146 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6147 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6148 // 1
6149 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6150 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6151 // 3
6152 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6153 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6154 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6155 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6156 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6157 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6158 // 9
6159 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6160 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6161 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6162 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6163 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6164 // 14
6165 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6166 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6167 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6168 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6169 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6170 // 19
6171 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6172 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6173 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6174 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6175 // 23
6176 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6177 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6178 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6179 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6180 // 27
6181 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6182 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6183 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6184 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6185 // 31
6186 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6187 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6188 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6189 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6190 // 35
6191 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6192 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6193 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6194 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6195 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6196 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6197 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6198 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6199 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6200 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6201 };
6202
6203 static DIALOG items_dlg[] =
6204 {
6205 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6206 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6207 //1
6208 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6209 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6210 // 3
6211 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6212 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6213 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6214 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6215 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6216 // 8
6217 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6218 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6219 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6220 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6221 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6222 // 13
6223 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6224 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6225 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6226 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6227 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6228 // 18
6229 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6230 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6231 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6232 // 21
6233 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6234 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6235 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6236 // 24
6237 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6238 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6239 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6240 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6241 // 28
6242 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6243 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6244 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6245 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6246 // 32
6247 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6248 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6249 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6250 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6251 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6252 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6253 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6254 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6255 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6256 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6257 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6258 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6259 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6260 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6261 //45
6262 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6263 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6264 };*/
6265
6266
6267
6268 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6269 {
6270 go();
6271 int32_t ret=0;
6272 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6273 comeback();
6274 return ret != 0;
6275 }
6276
6277
6278 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6279 {
6280 if(def!=modulepath)
6281 strcpy(modulepath,def);
6282
6283 if(!usefilename)
6284 {
6285 int32_t i=(int32_t)strlen(modulepath);
6286
6287 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6288 modulepath[i--]=0;
6289 }
6290
6291 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6292 int32_t ret=0;
6293 int32_t sel=0;
6294
6295 if(list==NULL)
6296 {
6297 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6298 }
6299 else
6300 {
6301 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6302 }
6303
6304 return ret!=0;
6305 }
6306
6307 //The Dialogue that loads a ZMOD Module File
6308 int32_t zc_load_zmod_module_file()
6309 {
6310 if ( Playing )
6311 {
6312 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6313 return -1;
6314 }
6315 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6316 return D_CLOSE;
6317
6318 FILE *tempmodule = fopen(modulepath,"r");
6319
6320 if(tempmodule == NULL)
6321 {
6322 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6323 return -1;
6324 }
6325
6326
6327 //Set the module path:
6328 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6329 strcpy(moduledata.module_name, modulepath);
6330 al_trace("New Module Path is: %s \n", moduledata.module_name);
6331 set_config_string("ZCMODULE","current_module",moduledata.module_name);
6332 //save_game_configs();
6333 zcm.init(true); //Load the module values.
6334 moduledata.refresh_title_screen = 1;
6335 // refresh_select_screen = 1;
6336 build_biic_list();
6337 return D_O_K;
6338 }
6339
6340 static DIALOG module_info_dlg[] =
6341 {
6342 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6343
6344
6345 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6346 //1
6347 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6348 //2
6349 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6350 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6351 //4
6352 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6353 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6354 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6355 //7
6356
6357 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6358 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6359 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6360 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6361 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6362 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6363 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6364 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6365 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6366
6367 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6368 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6369 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6370 };
6371
6372 void about_zcplayer_module(const char *prompt,int32_t initialval)
6373 {
6374
6375 module_info_dlg[0].dp2 = lfont;
6376 if ( moduledata.moduletitle[0] != 0 )
6377 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6378
6379 if ( moduledata.moduleauthor[0] != 0 )
6380 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6381
6382 if ( moduledata.moduleinfo0[0] != 0 )
6383 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6384 if ( moduledata.moduleinfo1[0] != 0 )
6385 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6386 if ( moduledata.moduleinfo2[0] != 0 )
6387 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6388 if ( moduledata.moduleinfo3[0] != 0 )
6389 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6390 if ( moduledata.moduleinfo4[0] != 0 )
6391 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6392
6393 char module_date[255];
6394 memset(module_date, 0, sizeof(module_date));
6395 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6396 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6397
6398
6399
6400 char module_vers[255];
6401 memset(module_vers, 0, sizeof(module_vers));
6402 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6403
6404
6405 //sprintf(tilecount,"%d",1);
6406
6407 char module_build[255];
6408 memset(module_build, 0, sizeof(module_build));
6409 if ( moduledata.modbeta )
6410 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6411 else
6412 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6413
6414 module_info_dlg[12].dp = (char*)module_date;
6415 module_info_dlg[13].dp = (char*)module_vers;
6416 module_info_dlg[14].dp = (char*)module_build;
6417
6418 if(is_large)
6419 large_dialog(module_info_dlg);
6420
6421 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6422 jwin_center_dialog(module_info_dlg);
6423
6424
6425 }
6426
6427 int32_t onAbout_ZCP_Module()
6428 {
6429 about_zcplayer_module("About Module (.zmod)", 0);
6430 return D_O_K;
6431 }
6432
6433 //New Modules Menu for 2.55+
6434 static MENU zcmodule_menu[] =
6435 {
6436 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6437 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6438
6439 { NULL, NULL, NULL, 0, NULL }
6440 };
6441
6442 int32_t onToggleRecordingNewSaves()
6443 {
6444 if (zc_get_config("zeldadx", "replay_new_saves", false))
6445 {
6446 zc_set_config("zeldadx", "replay_new_saves", false);
6447 }
6448 else
6449 {
6450 zc_set_config("zeldadx", "replay_new_saves", true);
6451 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6452 NULL,NULL,"OK",NULL,13,27,lfont);
6453 }
6454 return D_O_K;
6455 }
6456
6457 int32_t onStopReplayOrRecord()
6458 {
6459 if (replay_is_replaying())
6460 {
6461 replay_quit();
6462 }
6463 else if (replay_get_mode() == ReplayMode::Record)
6464 {
6465 if (!replay_get_meta_bool("test_mode"))
6466 {
6467 jwin_alert("Recording", "You cannot stop recording a save file.",
6468 NULL,NULL,"OK",NULL,13,27,lfont);
6469 return D_CLOSE;
6470 }
6471
6472 if (jwin_alert("Stop Recording",
6473 "Save replay to disk and stop recording?",
6474 "This will stop the recording.",
6475 NULL,
6476 "Yes","No",13,27,lfont) != 1)
6477 return D_CLOSE;
6478
6479 replay_save();
6480 replay_stop();
6481 }
6482 return D_O_K;
6483 }
6484
6485 static int32_t handle_on_load_replay(ReplayMode mode)
6486 {
6487 if (Playing)
6488 {
6489 if (jwin_alert("Replay - Warning!",
6490 "Loading a replay will exit the current game.",
6491 "All unsaved progress will be lost.",
6492 "Do you wish to continue?",
6493 "Yes","No",13,27,lfont) != 1)
6494 return D_CLOSE;
6495 }
6496
6497 std::string mode_string = replay_mode_to_string(mode);
6498 mode_string[0] = std::toupper(mode_string[0]);
6499
6500 std::string line_1 = "Select a replay file to play back.";
6501 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6502 std::string line_3 = "You can stop the replay and take over manually any time.";
6503 if (mode == ReplayMode::Update)
6504 {
6505 line_1 = "Select a replay file to update.";
6506 line_2 = "WARNING: be sure to back up the zplay file";
6507 line_3 = "and verify that the updated replay works as expected!";
6508 }
6509
6510 if (jwin_alert(mode_string.c_str(),
6511 line_1.c_str(),
6512 line_2.c_str(),
6513 line_3.c_str(),
6514 "OK","Nevermind",13,27,lfont) == 1)
6515 {
6516 char replay_path[2048];
6517 strcpy(replay_path, "replays/");
6518 if (jwin_file_select_ex(
6519 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6520 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6521 return D_CLOSE;
6522
6523 replay_quit();
6524 load_replay_file_deferred(mode, replay_path);
6525 Quit = qRESET;
6526 return D_CLOSE;
6527 }
6528 return D_O_K;
6529 }
6530
6531 int32_t onLoadReplay()
6532 {
6533 return handle_on_load_replay(ReplayMode::Replay);
6534 }
6535
6536 int32_t onLoadReplayAssert()
6537 {
6538 return handle_on_load_replay(ReplayMode::Assert);
6539 }
6540
6541 int32_t onLoadReplayUpdate()
6542 {
6543 return handle_on_load_replay(ReplayMode::Update);
6544 }
6545
6546 int32_t onSaveReplay()
6547 {
6548 if (replay_get_mode() == ReplayMode::Record)
6549 {
6550 if (!replay_get_meta_bool("test_mode"))
6551 {
6552 if (jwin_alert("Save Replay",
6553 "This will save a copy of the replay up to this point.",
6554 "The official replay file will be untouched.",
6555 "Do you wish to continue?",
6556 "Yes","No",13,27,lfont) != 1)
6557 return D_CLOSE;
6558
6559 char replay_path[2048];
6560 strcpy(replay_path, replay_get_filename().c_str());
6561 if (jwin_file_select_ex(
6562 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6563 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6564 return D_CLOSE;
6565
6566 if (fileexists(replay_path))
6567 {
6568 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6569 NULL,NULL,"OK",NULL,13,27,lfont);
6570 return D_CLOSE;
6571 }
6572
6573 replay_save(replay_path);
6574 }
6575 else
6576 {
6577 replay_save();
6578 }
6579 }
6580 return D_O_K;
6581 }
6582
6583 static MENU replay_menu[] =
6584 {
6585 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6586 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6587 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6588 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6589 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6590 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6591
6592 { NULL, NULL, NULL, 0, NULL }
6593 };
6594
6595 static DIALOG credits_dlg[] =
6596 {
6597 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6598 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6599 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6600 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6601 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6602 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6603 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6604 };
6605
6606 11 static ListData dmap_list(dmaplist, &font);
6607
6608 static DIALOG goto_dlg[] =
6609 {
6610 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6611 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6612 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6613 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6614 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6615 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6616 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6617 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6618 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6619 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6620 };
6621
6622 int32_t onGoTo()
6623 {
6624 bool music = false;
6625 music = music;
6626 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6627
6628 goto_dlg[0].dp2=lfont;
6629 goto_dlg[4].d2=cheat_goto_dmap;
6630 goto_dlg[6].dp=cheat_goto_screen_str;
6631
6632 clear_keybuf();
6633
6634 if(is_large)
6635 large_dialog(goto_dlg);
6636
6637 if(zc_popup_dialog(goto_dlg,4)==1)
6638 {
6639 // dmap, screen
6640 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6641 };
6642
6643 return D_O_K;
6644 }
6645
6646 int32_t onGoToComplete()
6647 {
6648 if(!Playing)
6649 {
6650 return D_O_K;
6651 }
6652
6653 system_pal();
6654 music_pause();
6655 pause_all_sfx();
6656 show_mouse(screen);
6657 onGoTo();
6658 eat_buttons();
6659
6660 zc_readrawkey(KEY_ESC);
6661
6662 show_mouse(NULL);
6663 game_pal();
6664 music_resume();
6665 resume_all_sfx();
6666 return D_O_K;
6667 }
6668
6669 int32_t onCredits()
6670 {
6671 go();
6672
6673 BITMAP *win = create_bitmap_ex(8,222,110);
6674
6675 if(!win)
6676 return D_O_K;
6677
6678 int32_t c=0;
6679 int32_t l=0;
6680 int32_t ol=-1;
6681 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6682 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6683 PALETTE tmppal;
6684
6685 rti_gui.transparency_index = 1;
6686
6687 clear_to_color(win, rti_gui.transparency_index);
6688 draw_rle_sprite(win,rle,0,0);
6689 credits_dlg[0].dp2=lfont;
6690 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6691 credits_dlg[2].dp = win;
6692
6693 set_palette_range(black_palette,0,127,false);
6694
6695 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6696
6697 BITMAP* old_screen = screen;
6698 BITMAP* gui_bmp = zc_get_gui_bmp();
6699 ASSERT(gui_bmp);
6700 clear_to_color(gui_bmp, rti_gui.transparency_index);
6701 screen = gui_bmp;
6702
6703 while(update_dialog(p))
6704 {
6705 throttleFPS();
6706 ++c;
6707 l = zc_max((c>>1)-30,0);
6708
6709 if(l > rle->h)
6710 l = c = 0;
6711
6712 if(l > rle->h - 112)
6713 l = rle->h - 112;
6714
6715 clear_bitmap(win);
6716 draw_rle_sprite(win,rle,0,0-l);
6717
6718 if(c<=64)
6719 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6720
6721 set_palette_range(tmppal,0,127,false);
6722
6723 if(l!=ol)
6724 {
6725 scare_mouse();
6726 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6727 unscare_mouse();
6728 SCRFIX();
6729 ol=l;
6730 }
6731
6732 update_hw_screen();
6733 }
6734
6735 screen = old_screen;
6736 system_pal();
6737
6738 shutdown_dialog(p);
6739 destroy_bitmap(win);
6740 //comeback();
6741
6742 rti_gui.transparency_index = 0;
6743
6744 return D_O_K;
6745 }
6746
6747 const char *midilist(int32_t index, int32_t *list_size)
6748 {
6749 if(index<0)
6750 {
6751 *list_size=0;
6752
6753 for(int32_t i=0; i<MAXMIDIS; i++)
6754 if(tunes[i].data)
6755 ++(*list_size);
6756
6757 return NULL;
6758 }
6759
6760 int32_t i=0,m=0;
6761
6762 while(m<=index && i<=MAXMIDIS)
6763 {
6764 if(tunes[i].data)
6765 ++m;
6766
6767 ++i;
6768 }
6769
6770 --i;
6771
6772 if(i==MAXMIDIS && m<index)
6773 return "(null)";
6774
6775 return tunes[i].title;
6776 }
6777
6778 /* ------- MIDI info stuff -------- */
6779
6780 char *text;
6781 midi_info *zmi;
6782 bool dialog_running;
6783 bool listening;
6784
6785 void get_info(int32_t index);
6786
6787 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6788 {
6789 int32_t d2 = d->d2;
6790 int32_t ret = jwin_droplist_proc(msg,d,c);
6791
6792 if(d2!=d->d2)
6793 {
6794 get_info(d->d2);
6795 }
6796
6797 return ret;
6798 }
6799
6800 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6801 {
6802 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6803
6804 int32_t ret = jwin_button_proc(msg,d,c);
6805
6806 if(ret == D_CLOSE)
6807 {
6808 // get current midi index
6809 int32_t index = (d+(d->d1))->d2;
6810 int32_t i=0, m=0;
6811
6812 while(m<=index && i<=MAXMIDIS)
6813 {
6814 if(tunes[i].data)
6815 ++m;
6816
6817 ++i;
6818 }
6819
6820 --i;
6821 jukebox(i);
6822 listening = true;
6823 ret = D_O_K;
6824 }
6825
6826 return ret;
6827 }
6828
6829 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6830 {
6831 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6832
6833 int32_t ret = jwin_button_proc(msg,d,c);
6834
6835 if(ret == D_CLOSE)
6836 {
6837 // get current midi index
6838 int32_t index = (d+(d->d1))->d2;
6839 int32_t i=0, m=0;
6840
6841 while(m<=index && i<=MAXMIDIS)
6842 {
6843 if(tunes[i].data)
6844 ++m;
6845
6846 ++i;
6847 }
6848
6849 --i;
6850
6851 // get file name
6852
6853 int32_t sel=0;
6854 //struct ffblk f;
6855 char title[40] = "Save MIDI: ";
6856 char fname[2048];
6857 memset(fname,0,2048);
6858 static EXT_LIST list[] =
6859 {
6860 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6861 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6862 { NULL, NULL }
6863 };
6864
6865 strcpy(title+11, tunes[i].title);
6866 title[39] = '\0';
6867
6868 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6869 goto done;
6870
6871 if(exists(fname))
6872 {
6873 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6874 goto done;
6875 }
6876
6877 // save midi i
6878
6879 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6880 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6881
6882 done:
6883 chop_path(fname);
6884 ret = D_REDRAW;
6885 }
6886
6887 return ret;
6888 }
6889
6890 11 static ListData midi_list(midilist, &font);
6891
6892 static DIALOG midi_dlg[] =
6893 {
6894 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6895 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6896 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6897 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6898 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6899 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6900 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6901 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6902 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6903 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6904 };
6905
6906 void get_info(int32_t index)
6907 {
6908 int32_t i=0, m=0;
6909
6910 while(m<=index && i<=MAXMIDIS)
6911 {
6912 if(tunes[i].data)
6913 ++m;
6914
6915 ++i;
6916 }
6917
6918 --i;
6919
6920 if(i==MAXMIDIS && m<index)
6921 strcpy(text,"(null)");
6922 else
6923 {
6924 get_midi_info((MIDI*)tunes[i].data,zmi);
6925 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6926 }
6927
6928 midi_dlg[0].dp2=lfont;
6929 midi_dlg[3].dp = text;
6930 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6931 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6932
6933 if(dialog_running)
6934 {
6935 scare_mouse();
6936 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6937 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6938 unscare_mouse();
6939 }
6940 }
6941
6942 int32_t onMIDICredits()
6943 {
6944 text = (char*)malloc(4096);
6945 zmi = (midi_info*)malloc(sizeof(midi_info));
6946
6947 if(!text || !zmi)
6948 {
6949 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6950 return D_O_K;
6951 }
6952
6953 bool do_pause_midi = midi_pos >= 0 && currmidi;
6954 auto restore_midi = currmidi;
6955 if(do_pause_midi)
6956 {
6957 paused_midi_pos = midi_pos;
6958 stop_midi();
6959 midi_paused=true;
6960 midi_suspended = midissuspHALTED;
6961 }
6962
6963 midi_dlg[0].dp2=lfont;
6964 midi_dlg[2].d1 = 0;
6965 midi_dlg[2].d2 = 0;
6966 midi_dlg[4].flags = D_EXIT;
6967 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6968
6969 listening = false;
6970 dialog_running=false;
6971 get_info(0);
6972
6973 dialog_running=true;
6974
6975 if(is_large)
6976 large_dialog(midi_dlg);
6977
6978 zc_popup_dialog(midi_dlg,0);
6979 dialog_running=false;
6980
6981 if(listening)
6982 music_stop();
6983
6984 if(do_pause_midi)
6985 {
6986 midi_suspended = midissuspRESUME;
6987 currmidi = restore_midi;
6988 midi_pos = paused_midi_pos;
6989 }
6990
6991 if(text) free(text);
6992 if(zmi) free(zmi);
6993 return D_O_K;
6994 }
6995
6996 int32_t onAbout()
6997 {
6998 char buf1[80]={0};
6999 std::ostringstream oss;
7000 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
7001 oss << buf1 << '\n';
7002 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
7003 oss << buf1 << '\n';
7004 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
7005 oss << buf1 << '\n';
7006 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
7007 oss << buf1 << '\n';
7008
7009 InfoDialog("About ZC", oss.str()).show();
7010 return D_O_K;
7011 }
7012
7013 int32_t onQuest()
7014 {
7015 char fname[100];
7016 strcpy(fname, get_filename(qstpath));
7017 quest_dlg[0].dp2=lfont;
7018 quest_dlg[1].dp = fname;
7019
7020 if(QHeader.quest_number==0)
7021 sprintf(str_a,"Custom");
7022 else
7023 sprintf(str_a,"%d",QHeader.quest_number);
7024
7025 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
7026
7027 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
7028 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
7029
7030 if(is_large)
7031 large_dialog(quest_dlg);
7032
7033 zc_popup_dialog(quest_dlg, 0);
7034 return D_O_K;
7035 }
7036
7037 void call_vidmode_dlg();
7038 int32_t onVidMode()
7039 {
7040 call_vidmode_dlg();
7041 return D_O_K;
7042 }
7043
7044 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
7045 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
7046 //Added an extra statement, so that if the key is cleared to 0, the cleared
7047 //keybinding status need not be unique. -Z ( 1st April, 2019 )
7048
7049 void load_ukeys(int32_t* arr)
7050 {
7051 arr[ukey_a] = Akey;
7052 arr[ukey_b] = Bkey;
7053 arr[ukey_s] = Skey;
7054 arr[ukey_l] = Lkey;
7055 arr[ukey_r] = Rkey;
7056 arr[ukey_p] = Pkey;
7057 arr[ukey_ex1] = Exkey1;
7058 arr[ukey_ex2] = Exkey2;
7059 arr[ukey_ex3] = Exkey3;
7060 arr[ukey_ex4] = Exkey4;
7061 arr[ukey_du] = DUkey;
7062 arr[ukey_dd] = DDkey;
7063 arr[ukey_dl] = DLkey;
7064 arr[ukey_dr] = DRkey;
7065 arr[ukey_mod1a] = cheat_modifier_keys[0];
7066 arr[ukey_mod1b] = cheat_modifier_keys[1];
7067 arr[ukey_mod2a] = cheat_modifier_keys[2];
7068 arr[ukey_mod2b] = cheat_modifier_keys[3];
7069 };
7070
7071 static const char* ukey_names[] = {
7072 "A", "B", "Start", "L", "R", "Map",
7073 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
7074 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
7075 "Cheat Mod R1", "Cheat Mod R2",
7076 };
7077 std::string get_ukey_name(int32_t k)
7078 {
7079 if (k < num_ukey) return ukey_names[k];
7080 return "";
7081 }
7082
7083 int32_t onKeyboard()
7084 {
7085 int32_t a = Akey;
7086 int32_t b = Bkey;
7087 int32_t s = Skey;
7088 int32_t l = Lkey;
7089 int32_t r = Rkey;
7090 int32_t p = Pkey;
7091 int32_t ex1 = Exkey1;
7092 int32_t ex2 = Exkey2;
7093 int32_t ex3 = Exkey3;
7094 int32_t ex4 = Exkey4;
7095 int32_t du = DUkey;
7096 int32_t dd = DDkey;
7097 int32_t dl = DLkey;
7098 int32_t dr = DRkey;
7099 int32_t mod1a = cheat_modifier_keys[0];
7100 int32_t mod1b = cheat_modifier_keys[1];
7101 int32_t mod2a = cheat_modifier_keys[2];
7102 int32_t mod2b = cheat_modifier_keys[3];
7103 bool done=false;
7104 int32_t ret;
7105
7106 keyboard_control_dlg[0].dp2=lfont;
7107
7108 if(is_large)
7109 large_dialog(keyboard_control_dlg);
7110
7111 while(!done)
7112 {
7113 ret = zc_popup_dialog(keyboard_control_dlg,3);
7114
7115 if(ret==3) // OK
7116 {
7117 int32_t ukeys[num_ukey];
7118 load_ukeys(ukeys);
7119 std::vector<std::string> uniqueError;
7120 for(int32_t q = 0; q < num_ukey; ++q)
7121 {
7122 for(int32_t p = q+1; p < num_ukey; ++p)
7123 {
7124 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7125 {
7126 char buf[64];
7127 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7128 std::string str(buf);
7129 uniqueError.push_back(str);
7130 }
7131 }
7132 }
7133 if(uniqueError.size() == 0)
7134 done = true;
7135 else
7136 {
7137 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7138 box_out("Cannot have duplicate keybinds!"); box_eol();
7139 for(std::vector<std::string>::iterator it = uniqueError.begin();
7140 it != uniqueError.end(); ++it)
7141 {
7142 box_out((*it).c_str()); box_eol();
7143 }
7144 box_end(true);
7145 }
7146 /* Old uniqueness check
7147 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7148 bool unique = true;
7149 addToHash(A,unique,keyhash);
7150 addToHash(B,unique,keyhash);
7151 addToHash(S,unique,keyhash);
7152 addToHash(L,unique,keyhash);
7153 addToHash(R,unique,keyhash);
7154 addToHash(P,unique,keyhash);
7155 addToHash(DU,unique,keyhash);
7156 addToHash(DD,unique,keyhash);
7157 addToHash(DL,unique,keyhash);
7158 addToHash(DR,unique,keyhash);
7159
7160 if(keyhash->find(Exkey1) == keyhash->end())
7161 {
7162 (*keyhash)[Exkey1]=true;
7163 }
7164 else
7165 {
7166 if ( Exkey1 != 0 ) unique = false;
7167 }
7168
7169 if(keyhash->find(Exkey2) == keyhash->end())
7170 {
7171 (*keyhash)[Exkey2]=true;
7172 }
7173 else
7174 {
7175 if ( Exkey2 != 0 ) unique = false;
7176 }
7177
7178 if(keyhash->find(Exkey3) == keyhash->end())
7179 {
7180 (*keyhash)[Exkey3]=true;
7181 }
7182 else
7183 {
7184 if ( Exkey3 != 0 ) unique = false;
7185 }
7186
7187 if(keyhash->find(Exkey4) == keyhash->end())
7188 {
7189 (*keyhash)[Exkey4]=true;
7190 }
7191 else
7192 {
7193 if ( Exkey4 != 0 )unique = false;
7194 }
7195 //modifier keys
7196 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7197 {
7198 (*keyhash)[cheat_modifier_keys[0]]=true;
7199 }
7200 else
7201 {
7202 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7203 }
7204 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7205 {
7206 (*keyhash)[cheat_modifier_keys[1]]=true;
7207 }
7208 else
7209 {
7210 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7211 }
7212 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7213 {
7214 (*keyhash)[cheat_modifier_keys[2]]=true;
7215 }
7216 else
7217 {
7218 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7219 }
7220 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7221 {
7222 (*keyhash)[cheat_modifier_keys[3]]=true;
7223 }
7224 else
7225 {
7226 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7227 }
7228
7229 delete keyhash;
7230
7231 if(unique)
7232 done=true;
7233 else
7234 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7235 */
7236 }
7237 else // Cancel
7238 {
7239 Akey = a;
7240 Bkey = b;
7241 Skey = s;
7242 Lkey = l;
7243 Rkey = r;
7244 Pkey = p;
7245 Exkey1 = ex1;
7246 Exkey2 = ex2;
7247 Exkey3 = ex3;
7248 Exkey4 = ex4;
7249 DUkey = du;
7250 DDkey = dd;
7251 DLkey = dl;
7252 DRkey = dr;
7253 cheat_modifier_keys[0] = mod1a;
7254 cheat_modifier_keys[1] = mod1b;
7255 cheat_modifier_keys[2] = mod2a;
7256 cheat_modifier_keys[3] = mod2b;
7257
7258 done=true;
7259 }
7260
7261 rest(1);
7262 }
7263
7264 save_game_configs();
7265 return D_O_K;
7266 }
7267
7268 int32_t onGamepad()
7269 {
7270 int32_t a = Abtn;
7271 int32_t b = Bbtn;
7272 int32_t s = Sbtn;
7273 int32_t l = Lbtn;
7274 int32_t r = Rbtn;
7275 int32_t m = Mbtn;
7276 int32_t p = Pbtn;
7277 int32_t ex1 = Exbtn1;
7278 int32_t ex2 = Exbtn2;
7279 int32_t ex3 = Exbtn3;
7280 int32_t ex4 = Exbtn4;
7281 int32_t up = DUbtn;
7282 int32_t down = DDbtn;
7283 int32_t left = DLbtn;
7284 int32_t right = DRbtn;
7285
7286 gamepad_dlg[0].dp2=lfont;
7287 if(analog_movement)
7288 gamepad_dlg[56].flags|=D_SELECTED;
7289 else
7290 gamepad_dlg[56].flags&=~D_SELECTED;
7291
7292 if(is_large)
7293 large_dialog(gamepad_dlg);
7294
7295 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7296
7297 if(ret == 4) //OK
7298 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7299 else //Cancel
7300 {
7301 Abtn = a;
7302 Bbtn = b;
7303 Sbtn = s;
7304 Lbtn = l;
7305 Rbtn = r;
7306 Mbtn = m;
7307 Pbtn = p;
7308 Exbtn1 = ex1;
7309 Exbtn2 = ex2;
7310 Exbtn3 = ex3;
7311 Exbtn4 = ex4;
7312 DUbtn = up;
7313 DDbtn = down;
7314 DLbtn = left;
7315 DRbtn = right;
7316 }
7317
7318 save_game_configs();
7319 return D_O_K;
7320 }
7321
7322 int32_t onSound()
7323 {
7324 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7325 {
7326 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7327 }
7328 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7329 {
7330 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7331 }
7332 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7333 {
7334 emusic_volume = (int32_t)FFCore.usr_music_volume;
7335 }
7336 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7337 {
7338 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7339 }
7340 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7341 {
7342 pan_style = (int32_t)FFCore.usr_panstyle;
7343 }
7344
7345 int32_t m = midi_volume;
7346 int32_t d = digi_volume;
7347 int32_t e = emusic_volume;
7348 int32_t b = zcmusic_bufsz;
7349 int32_t s = sfx_volume;
7350 int32_t p = pan_style;
7351 pan_style = vbound(pan_style,0,3);
7352
7353 sound_dlg[0].dp2=lfont;
7354
7355 if(is_large)
7356 large_dialog(sound_dlg);
7357
7358 midi_dp[1] = sound_dlg[6].x;
7359 midi_dp[2] = sound_dlg[6].y;
7360 digi_dp[1] = sound_dlg[7].x;
7361 digi_dp[2] = sound_dlg[7].y;
7362 emus_dp[1] = sound_dlg[8].x;
7363 emus_dp[2] = sound_dlg[8].y;
7364 buf_dp[1] = sound_dlg[9].x;
7365 buf_dp[2] = sound_dlg[9].y;
7366 sfx_dp[1] = sound_dlg[10].x;
7367 sfx_dp[2] = sound_dlg[10].y;
7368 pan_dp[1] = sound_dlg[11].x;
7369 pan_dp[2] = sound_dlg[11].y;
7370 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7371 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7372 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7373 sound_dlg[18].d2 = zcmusic_bufsz;
7374 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7375 sound_dlg[20].d2 = pan_style;
7376
7377 int32_t ret = zc_popup_dialog(sound_dlg,1);
7378
7379 if(ret==2)
7380 {
7381 master_volume(digi_volume,midi_volume);
7382
7383 for(int32_t i=0; i<WAV_COUNT; ++i)
7384 {
7385 //allegro assertion fails when passing in -1 as voice -DD
7386 if(sfx_voice[i] > 0)
7387 voice_set_volume(sfx_voice[i], sfx_volume);
7388 }
7389 }
7390 else
7391 {
7392 midi_volume = m;
7393 digi_volume = d;
7394 emusic_volume = e;
7395 zcmusic_bufsz = b;
7396 sfx_volume = s;
7397 pan_style = p;
7398 }
7399
7400 save_game_configs();
7401 return D_O_K;
7402 }
7403
7404 int32_t queding(char const* s1, char const* s2, char const* s3)
7405 {
7406 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7407 }
7408
7409 int32_t onQuit()
7410 {
7411 if(Playing)
7412 {
7413 int32_t ret=0;
7414
7415 if(get_bit(quest_rules, qr_NOCONTINUE))
7416 {
7417 if(standalone_mode)
7418 {
7419 ret=queding("End current game?",
7420 "The continue screen is disabled; the game",
7421 "will be reloaded from the last save.");
7422 }
7423 else
7424 {
7425 ret=queding("End current game?",
7426 "The continue screen is disabled. You will",
7427 "be returned to the file select screen.");
7428 }
7429 }
7430 else
7431 ret=queding("End current game?",NULL,NULL);
7432
7433 if(ret==1)
7434 {
7435 disableClickToFreeze=false;
7436 Quit=qQUIT;
7437
7438 // Trying to evade a door repair charge?
7439 if(repaircharge)
7440 {
7441 game->change_drupy(-repaircharge);
7442 repaircharge=0;
7443 }
7444
7445 return D_CLOSE;
7446 }
7447 }
7448
7449 return D_O_K;
7450 }
7451
7452 int32_t onTryQuitMenu()
7453 {
7454 return onTryQuit(true);
7455 }
7456
7457 int32_t onTryQuit(bool inMenu)
7458 {
7459 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7460 {
7461 if(get_bit(quest_rules,qr_OLD_F6))
7462 {
7463 if(inMenu) onQuit();
7464 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7465 }
7466 else
7467 {
7468 disableClickToFreeze=false;
7469 GameFlags |= GAMEFLAG_TRYQUIT;
7470 }
7471 return D_CLOSE;
7472 }
7473
7474 return D_O_K;
7475 }
7476
7477 int32_t onReset()
7478 {
7479 if(queding(" Reset system? ",NULL,NULL)==1)
7480 {
7481 disableClickToFreeze=false;
7482 Quit=qRESET;
7483 replay_quit();
7484 return D_CLOSE;
7485 }
7486
7487 return D_O_K;
7488 }
7489
7490 int32_t onExit()
7491 {
7492 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7493 {
7494 Quit=qEXIT;
7495 return D_CLOSE;
7496 }
7497
7498 return D_O_K;
7499 }
7500
7501 int32_t onTitle_NES()
7502 {
7503 title_version=0;
7504 return D_O_K;
7505 }
7506 int32_t onTitle_DX()
7507 {
7508 title_version=1;
7509 return D_O_K;
7510 }
7511 int32_t onTitle_25()
7512 {
7513 title_version=2;
7514 return D_O_K;
7515 }
7516
7517 int32_t onDebug()
7518 {
7519 if(debug_enabled)
7520 set_debug(!get_debug());
7521 save_game_configs();
7522 return D_O_K;
7523 }
7524
7525 int32_t onHeartBeep()
7526 {
7527 heart_beep=!heart_beep;
7528 save_game_configs();
7529 return D_O_K;
7530 }
7531
7532 int32_t onSaveIndicator()
7533 {
7534 use_save_indicator=!use_save_indicator;
7535 save_game_configs();
7536 return D_O_K;
7537 }
7538
7539 int32_t onEpilepsy()
7540 {
7541 if(jwin_alert3(
7542 "Epilepsy Flash Reduction",
7543 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7544 "Disabling this will restore standard flash and wavy behaviour.",
7545 "Proceed?",
7546 "&Yes",
7547 "&No",
7548 NULL,
7549 'y',
7550 'n',
7551 0,
7552 lfont) == 1)
7553 {
7554 if ( epilepsyFlashReduction ) epilepsyFlashReduction = 0;
7555 else epilepsyFlashReduction = 1;
7556 set_config_int("zeldadx","checked_epilepsy",1);
7557 save_game_configs();
7558 }
7559 return D_O_K;
7560 }
7561
7562 int32_t onTriforce()
7563 {
7564 for(int32_t i=0; i<MAXINITTABS; ++i)
7565 {
7566 init_tabs[i].flags&=~D_SELECTED;
7567 }
7568
7569 init_tabs[3].flags=D_SELECTED;
7570 return onCheatConsole();
7571 /*triforce_dlg[0].dp2=lfont;
7572 for(int32_t i=1; i<=8; i++)
7573 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7574
7575 if(zc_popup_dialog (triforce_dlg,-1)==9)
7576 {
7577 for(int32_t i=1; i<=8; i++)
7578 {
7579 game->lvlitems[i] &= ~liTRIFORCE;
7580 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7581 }
7582 }
7583 return D_O_K;*/
7584 }
7585
7586 bool rc = false;
7587 /*
7588 int32_t onEquipment()
7589 {
7590 for (int32_t i=0; i<MAXINITTABS; ++i)
7591 {
7592 init_tabs[i].flags&=~D_SELECTED;
7593 }
7594 init_tabs[0].flags=D_SELECTED;
7595 return onCheatConsole();
7596 }
7597 */
7598
7599 int32_t onItems()
7600 {
7601 for(int32_t i=0; i<MAXINITTABS; ++i)
7602 {
7603 init_tabs[i].flags&=~D_SELECTED;
7604 }
7605
7606 init_tabs[1].flags=D_SELECTED;
7607 return onCheatConsole();
7608 }
7609
7610 static DIALOG getnum_dlg[] =
7611 {
7612 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7613 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7614 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7615 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7616 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7617 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7618 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7619 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7620 };
7621
7622 int32_t getnumber(const char *prompt,int32_t initialval)
7623 {
7624 char buf[20];
7625 sprintf(buf,"%d",initialval);
7626 getnum_dlg[0].dp=(void *)prompt;
7627 getnum_dlg[0].dp2=lfont;
7628 getnum_dlg[2].dp=buf;
7629
7630 if(is_large)
7631 large_dialog(getnum_dlg);
7632
7633 if(zc_popup_dialog(getnum_dlg,2)==3)
7634 return atoi(buf);
7635
7636 return initialval;
7637 }
7638
7639 int32_t onLife()
7640 {
7641 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7642 cheats_enqueue(Cheat::Life, value);
7643 return D_O_K;
7644 }
7645
7646 int32_t onHeartC()
7647 {
7648 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7649 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7650 cheats_enqueue(Cheat::MaxLife, max_life);
7651 cheats_enqueue(Cheat::Life, life);
7652 return D_O_K;
7653 }
7654
7655 int32_t onMagicC()
7656 {
7657 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7658 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7659 cheats_enqueue(Cheat::MaxMagic, max_magic);
7660 cheats_enqueue(Cheat::Magic, magic);
7661 return D_O_K;
7662 }
7663
7664 int32_t onRupies()
7665 {
7666 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7667 cheats_enqueue(Cheat::Rupies, value);
7668 return D_O_K;
7669 }
7670
7671 int32_t onMaxBombs()
7672 {
7673 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7674 cheats_enqueue(Cheat::MaxBombs, value);
7675 cheats_enqueue(Cheat::Bombs, value);
7676 return D_O_K;
7677 }
7678
7679 int32_t onRefillLife()
7680 {
7681 cheats_enqueue(Cheat::Life, game->get_maxlife());
7682 return D_O_K;
7683 }
7684 int32_t onRefillMagic()
7685 {
7686 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7687 return D_O_K;
7688 }
7689 int32_t onClock()
7690 {
7691 cheats_enqueue(Cheat::Clock);
7692 return D_O_K;
7693 }
7694
7695 int32_t onQstPath()
7696 {
7697 char path[2048];
7698
7699 chop_path(qstdir);
7700 strcpy(path,qstdir);
7701
7702 go();
7703
7704 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7705 {
7706 chop_path(path);
7707 fix_filename_case(path);
7708 fix_filename_slashes(path);
7709 strcpy(qstdir,path);
7710 strcpy(qstpath,qstdir);
7711 }
7712
7713 comeback();
7714 return D_O_K;
7715 }
7716
7717 #include "dialog/cheat_dialog.h"
7718 int32_t onCheat()
7719 {
7720 call_setcheat_dialog();
7721 game->set_cheat(maxcheat);
7722 if(cheat) game->did_cheat(true);
7723 return D_O_K;
7724 }
7725
7726 int32_t onCheatRupies()
7727 {
7728 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7729 return D_O_K;
7730 }
7731
7732 int32_t onCheatArrows()
7733 {
7734 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7735 return D_O_K;
7736 }
7737
7738 int32_t onCheatBombs()
7739 {
7740 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7741 return D_O_K;
7742 }
7743
7744 // *** screen saver
7745
7746 955876 int32_t after_time()
7747 {
7748
1/2
✓ Branch 0 taken 955876 times.
✗ Branch 1 not taken.
955876 if(ss_enable == 0)
7749 return INT_MAX;
7750
7751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
955876 if(ss_after <= 0)
7752 return 5 * 60;
7753
7754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
955876 if(ss_after <= 3)
7755 return ss_after * 15 * 60;
7756
7757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 955876 times.
955876 if(ss_after <= 13)
7758 return (ss_after - 3) * 60 * 60;
7759
7760 955876 return MAX_IDLE + 1;
7761 955876 }
7762
7763 static const char *after_str[15] =
7764 {
7765 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7766 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7767 "Never"
7768 };
7769
7770 const char *after_list(int32_t index, int32_t *list_size)
7771 {
7772 if(index < 0)
7773 {
7774 *list_size = 15;
7775 return NULL;
7776 }
7777
7778 return after_str[index];
7779 }
7780
7781 11 static ListData after__list(after_list, &font);
7782
7783 static DIALOG scrsaver_dlg[] =
7784 {
7785 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7786 11 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7787 11 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7788 11 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7789 11 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7790 11 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7791 11 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7792 11 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7793 11 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7794 11 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7795 11 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7796 11 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7797 11 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7798 11 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7799 };
7800
7801 int32_t onScreenSaver()
7802 {
7803 scrsaver_dlg[0].dp2=lfont;
7804 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = ss_after;
7805 scrsaver_dlg[6].d2 = ss_speed;
7806 scrsaver_dlg[7].d2 = ss_density;
7807
7808 if(is_large)
7809 large_dialog(scrsaver_dlg);
7810
7811 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7812
7813 if(ret == 8 || ret == 9)
7814 {
7815 ss_after = scrsaver_dlg[5].d1;
7816 ss_speed = scrsaver_dlg[6].d2;
7817 ss_density = scrsaver_dlg[7].d2;
7818 }
7819
7820 if(ret == 9)
7821 // preview Screen Saver
7822 {
7823 clear_keybuf();
7824 scare_mouse();
7825 Matrix(ss_speed, ss_density, 30);
7826 system_pal();
7827 unscare_mouse();
7828 }
7829
7830 return D_O_K;
7831 }
7832
7833 /***** Menus *****/
7834
7835 static MENU game_menu[] =
7836 {
7837 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7838 { (char *)"", NULL, NULL, 0, NULL },
7839 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7840 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7841 { (char *)"", NULL, NULL, 0, NULL },
7842 #ifdef __EMSCRIPTEN__
7843 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7844 #elif defined(ALLEGRO_MACOSX)
7845 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7846 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7847 #else
7848 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7849 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7850 #endif
7851 { NULL, NULL, NULL, 0, NULL }
7852 };
7853
7854 static MENU title_menu[] =
7855 {
7856 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7857 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7858 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7859 { NULL, NULL, NULL, 0, NULL }
7860 };
7861
7862 static MENU snapshot_format_menu[] =
7863 {
7864 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7865 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7866 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7867 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7868 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7869 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7870 { NULL, NULL, NULL, 0, NULL }
7871 };
7872
7873 static MENU controls_menu[] =
7874 {
7875 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7876 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7877 { NULL, NULL, NULL, 0, NULL }
7878 };
7879
7880 static MENU name_entry_mode_menu[] =
7881 {
7882 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7883 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7884 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7885 { NULL, NULL, NULL, 0, NULL }
7886 };
7887
7888 static void set_controls_menu_active()
7889 {
7890
7891 }
7892
7893 static MENU settings_menu[] =
7894 {
7895 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7896 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7897 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7898 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7899 { (char *)"", NULL, NULL, 0, NULL },
7900 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7901 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7902 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7903 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7904 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7905 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7906 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7907 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7908 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7909 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7910 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7911 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7912 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7913 { (char *)"", NULL, NULL, 0, NULL },
7914 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7915 { (char *)"", NULL, NULL, 0, NULL },
7916 { NULL, NULL, NULL, 0, NULL }
7917 };
7918
7919
7920 static MENU misc_menu[] =
7921 {
7922 { (char *)"&About...", onAbout, NULL, 0, NULL },
7923 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7924 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7925 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7926 { (char *)"", NULL, NULL, 0, NULL },
7927 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7928 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7929 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7930 { (char *)"", NULL, NULL, 0, NULL },
7931 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7932 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7933 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7934 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7935 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7936 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7937 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7938 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7939
7940 { NULL, NULL, NULL, 0, NULL }
7941 };
7942
7943 static MENU refill_menu[] =
7944 {
7945 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7946 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7947 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7948 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7949 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7950 { NULL, NULL, NULL, 0, NULL }
7951 };
7952
7953 static MENU show_menu[] =
7954 {
7955 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7956 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7957 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7958 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7959 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7960 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7961 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7962 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7963 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7964 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7965 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7966 { (char *)"", NULL, NULL, 0, NULL },
7967 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7968 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7969 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7970 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7971 { NULL, NULL, NULL, 0, NULL }
7972 };
7973
7974 static MENU cheat_menu[] =
7975 {
7976 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7977 { (char *)"", NULL, NULL, 0, NULL },
7978 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7979 { (char *)"", NULL, NULL, 0, NULL },
7980 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7981 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7982 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7983 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7984 { (char *)"", NULL, NULL, 0, NULL },
7985 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7986 { (char *)"", NULL, NULL, 0, NULL },
7987 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7988 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7989 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7990 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7991 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7992 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
7993 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
7994 { NULL, NULL, NULL, 0, NULL }
7995 };
7996
7997 static MENU fixes_menu[] =
7998 {
7999 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
8000 { NULL, NULL, NULL, 0, NULL }
8001 };
8002
8003 #if DEVLEVEL > 0
8004 int32_t devLogging();
8005 int32_t devDebug();
8006 int32_t devTimestmp();
8007 #if DEVLEVEL > 1
8008 int32_t setCheat();
8009 #endif //DEVLEVEL > 1
8010 static MENU dev_menu[] =
8011 {
8012 { (char *)"&Force Error Log", devLogging, NULL, D_SELECTED, NULL },
8013 { (char *)"&Extra Debug Log", devDebug, NULL, D_SELECTED, NULL },
8014 { (char *)"&Timestamp Log", devTimestmp, NULL, D_SELECTED, NULL },
8015 #if DEVLEVEL > 1
8016 { (char *)"", NULL, NULL, 0, NULL },
8017 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
8018 #endif //DEVLEVEL > 1
8019 { NULL, NULL, NULL, 0, NULL }
8020 };
8021 int32_t devLogging()
8022 {
8023 dev_logging = !dev_logging;
8024 dev_menu[0].flags = dev_logging ? D_SELECTED : 0;
8025 return D_O_K;
8026 }
8027 int32_t devDebug()
8028 {
8029 dev_debug = !dev_debug;
8030 dev_menu[1].flags = dev_debug ? D_SELECTED : 0;
8031 return D_O_K;
8032 }
8033 int32_t devTimestmp()
8034 {
8035 dev_timestmp = !dev_timestmp;
8036 dev_menu[2].flags = dev_timestmp ? D_SELECTED : 0;
8037 return D_O_K;
8038 }
8039 #if DEVLEVEL > 1
8040 int32_t setCheat()
8041 {
8042 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
8043 return D_O_K;
8044 }
8045 #endif //DEVLEVEL > 1
8046 #endif //DEVLEVEL > 0
8047
8048 MENU the_player_menu[] =
8049 {
8050 { (char *)"&Game", NULL, game_menu, 0, NULL },
8051 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8052 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
8053 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8054 #if DEVLEVEL > 0
8055 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8056 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8057 { NULL, NULL, NULL, 0, NULL }
8058 #else
8059 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8060 { NULL, NULL, NULL, 0, NULL }
8061 #endif
8062 };
8063
8064 MENU the_player_menu2[] =
8065 {
8066 { (char *)"&Game", NULL, game_menu, 0, NULL },
8067 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8068 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8069
8070 #if DEVLEVEL > 0
8071 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8072 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8073 { NULL, NULL, NULL, 0, NULL }
8074 #else
8075 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8076 { NULL, NULL, NULL, 0, NULL }
8077 #endif
8078
8079 };
8080
8081 int32_t onMIDIPatch()
8082 {
8083 if(jwin_alert3(
8084 "Toggle Windows MIDI Fix",
8085 "This action will change whether ZC Player auto-restarts a MIDI at its",
8086 "last index if you move ZC Player out of focus, then back into focus.",
8087 "Proceed?",
8088 "&Yes",
8089 "&No",
8090 NULL,
8091 'y',
8092 'n',
8093 0,
8094 lfont) == 1)
8095 {
8096 if (midi_patch_fix) midi_patch_fix = 0;
8097
8098 else midi_patch_fix = 1;
8099
8100 }
8101 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8102 save_game_configs();
8103 return D_O_K;
8104 }
8105
8106 int32_t onKeyboardEntry()
8107 {
8108 NameEntryMode=0;
8109 return D_O_K;
8110 }
8111
8112 int32_t onLetterGridEntry()
8113 {
8114 NameEntryMode=1;
8115 return D_O_K;
8116 }
8117
8118 int32_t onExtLetterGridEntry()
8119 {
8120 NameEntryMode=2;
8121 return D_O_K;
8122 }
8123
8124 static BITMAP* oldscreen;
8125 int32_t onFullscreenMenu()
8126 {
8127 // super hacks
8128 screen = oldscreen;
8129 if (onFullscreen() == D_REDRAW)
8130 {
8131 oldscreen = screen;
8132 }
8133 screen = menu_bmp;
8134 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8135 return D_O_K;
8136 }
8137
8138 11 void fix_menu()
8139 {
8140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!debug_enabled)
8141 11 settings_menu[18].text = NULL;
8142 11 }
8143
8144 static DIALOG system_dlg[] =
8145 {
8146 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8147 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8148 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8149 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8150 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8151 #ifndef ALLEGRO_MACOSX
8152 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8153 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8154 #else
8155 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8156 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8157 #endif
8158 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8159 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8160 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8161 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8162 };
8163
8164 static DIALOG system_dlg2[] =
8165 {
8166 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8167 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8168 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8169 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8170 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8171 #ifndef ALLEGRO_MACOSX
8172 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8173 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8174 #else
8175 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8176 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8177 #endif
8178 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8179 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8180 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8181 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8182 };
8183
8184 void reset_snapshot_format_menu()
8185 {
8186 for(int32_t i=0; i<ssfmtMAX; ++i)
8187 {
8188 snapshot_format_menu[i].flags=0;
8189 }
8190 }
8191
8192 int32_t onSetSnapshotFormat()
8193 {
8194 switch(active_menu->text[1])
8195 {
8196 case 'B': //"&BMP"
8197 SnapshotFormat=0;
8198 break;
8199
8200 case 'G': //"&GIF"
8201 SnapshotFormat=1;
8202 break;
8203
8204 case 'J': //"&JPG"
8205 SnapshotFormat=2;
8206 break;
8207
8208 case 'P': //"&PNG"
8209 SnapshotFormat=3;
8210 break;
8211
8212 case 'C': //"PC&X"
8213 SnapshotFormat=4;
8214 break;
8215
8216 case 'T': //"&TGA"
8217 SnapshotFormat=5;
8218 break;
8219
8220 case 'L': //"&LBM"
8221 SnapshotFormat=6;
8222 break;
8223 }
8224
8225 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8226 return D_O_K;
8227 }
8228
8229
8230 12 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8231 {
8232 PALETTE tmp;
8233
8234
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<256; i++)
8235 {
8236 3072 tmp[i].r=r;
8237 3072 tmp[i].g=g;
8238 3072 tmp[i].b=b;
8239 3072 }
8240
8241 12 fade_interpolate(src,tmp,dest,pos,from,to);
8242 12 }
8243
8244 12 void system_pal()
8245 {
8246 12 is_sys_pal = true;
8247 static PALETTE pal;
8248 12 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8249
8250 // set up the grayscale palette
8251
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 12 times.
780 for(int32_t i=128; i<192; i++)
8252 {
8253 768 pal[i].r = i-128;
8254 768 pal[i].g = i-128;
8255 768 pal[i].b = i-128;
8256 768 }
8257 12 load_colorset(gui_colorset, pal);
8258
8259 12 color_layer(pal, pal, 24,16,16, 28, 128,191);
8260
8261
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 12 times.
1548 for(int32_t i=0; i<256; i+=2)
8262 {
8263 1536 int32_t v = (i>>3)+2;
8264 1536 int32_t c = (i>>3)+192;
8265 1536 pal[c] = _RGB(v,v,v+(v>>1));
8266 /*
8267 if(i<240)
8268 {
8269 _allegro_hline(tmp_scr,0,i,319,c);
8270 _allegro_hline(tmp_scr,0,i+1,319,c);
8271 }
8272 */
8273 1536 }
8274
8275 // draw the vertical screen gradient
8276
2/2
✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 12 times.
2892 for(int32_t i=0; i<240; ++i)
8277 {
8278 2880 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8279 2880 }
8280
8281 /*
8282 palrstart= 10*63/255; palrend=166*63/255;
8283 palgstart= 36*63/255; palgend=202*63/255;
8284 palbstart=106*63/255; palbend=240*63/255;
8285 paldivs=32;
8286 for(int32_t i=0; i<paldivs; i++)
8287 {
8288 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8289 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8290 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8291 }
8292 */
8293 12 BITMAP *panorama = create_bitmap_ex(8,256,224);
8294 int32_t ts_height, ts_start;
8295
8296
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8297 {
8298 clear_to_color(panorama,0);
8299 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8300 ts_height=224-passive_subscreen_height;
8301 ts_start=28;
8302 }
8303 else
8304 {
8305 12 blit(framebuf,panorama,0,0,0,0,256,224);
8306 12 ts_height=224;
8307 12 ts_start=0;
8308 }
8309
8310 // gray scale the current frame
8311
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 12 times.
2700 for(int32_t y=0; y<ts_height; y++)
8312 {
8313
2/2
✓ Branch 0 taken 688128 times.
✓ Branch 1 taken 2688 times.
690816 for(int32_t x=0; x<256; x++)
8314 {
8315 688128 int32_t c = panorama->line[y+ts_start][x];
8316
2/2
✓ Branch 0 taken 687647 times.
✓ Branch 1 taken 481 times.
688128 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8317 688128 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8318 688128 }
8319 2688 }
8320
8321 12 destroy_bitmap(panorama);
8322
8323 // display everything
8324 12 vsync();
8325 12 hw_palette = &pal;
8326 12 update_hw_pal = true;
8327
8328 // sys_pal = pal;
8329 12 memcpy(sys_pal,pal,sizeof(pal));
8330 12 }
8331
8332 void system_pal2()
8333 {
8334 is_sys_pal = true;
8335 static PALETTE RAMpal2;
8336 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8337
8338 /* Windows 2000 colors
8339 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8340 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8341 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8342 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8343 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8344 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8345 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8346 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8347
8348 byte palrstart= 10*63/255, palrend=166*63/255,
8349 palgstart= 36*63/255, palgend=202*63/255,
8350 palbstart=106*63/255, palbend=240*63/255,
8351 paldivs=7;
8352 for(int32_t i=0; i<paldivs; i++)
8353 {
8354 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8355 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8356 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8357 }
8358 */
8359
8360 /* Windows 98 colors
8361 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8362 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8363 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8364 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8365 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8366 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8367 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8368 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8369
8370 byte palrstart= 0*63/255, palrend=166*63/255,
8371 palgstart= 0*63/255, palgend=202*63/255,
8372 palbstart=128*63/255, palbend=240*63/255,
8373 paldivs=7;
8374 for(int32_t i=0; i<paldivs; i++)
8375 {
8376 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8377 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8378 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8379 }
8380 */
8381
8382 /* Windows 99 colors
8383 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8384 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8385 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8386 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8387 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8388 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8389 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8390 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8391 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8392
8393 byte palrstart= 0*63/255, palrend=166*63/255,
8394 palgstart= 0*63/255, palgend=202*63/255,
8395
8396 palbstart=128*63/255, palbend=240*63/255,
8397 paldivs=6;
8398 for(int32_t i=0; i<paldivs; i++)
8399 {
8400 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8401 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8402 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8403 }
8404 */
8405
8406
8407
8408 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8409 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8410 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8411 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8412 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8413 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8414 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8415 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8416 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8417
8418 byte palrstart= 0*63/255, palrend=166*63/255,
8419 palgstart= 0*63/255, palgend=202*63/255,
8420 palbstart=128*63/255, palbend=240*63/255,
8421 paldivs=6;
8422
8423 for(int32_t i=0; i<paldivs; i++)
8424 {
8425 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8426 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8427 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8428 }
8429
8430 gui_bg_color=jwin_pal[jcBOX];
8431 gui_fg_color=jwin_pal[jcBOXFG];
8432
8433 jwin_set_colors(jwin_pal);
8434
8435
8436 // set up the new palette
8437 for(int32_t i=128; i<192; i++)
8438 {
8439 RAMpal2[i].r = i-128;
8440 RAMpal2[i].g = i-128;
8441 RAMpal2[i].b = i-128;
8442 }
8443
8444 /*
8445 for(int32_t i=0; i<64; i++)
8446 {
8447 RAMpal2[128+i] = _RGB(i,i,i)1));
8448 }
8449 */
8450
8451 /*
8452
8453 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8454 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8455 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8456 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8457 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8458 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8459 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8460
8461 gui_fg_color=vc(14);
8462 gui_bg_color=vc(1);
8463
8464 jwin_set_colors(jwin_pal);
8465 */
8466
8467 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8468
8469 // set up the colors for the vertical screen gradient
8470 for(int32_t i=0; i<256; i+=2)
8471 {
8472 int32_t v = (i>>3)+2;
8473 int32_t c = (i>>3)+192;
8474 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8475
8476 /*
8477 if(i<240)
8478 {
8479 _allegro_hline(tmp_scr,0,i,319,c);
8480 _allegro_hline(tmp_scr,0,i+1,319,c);
8481 }
8482 */
8483 }
8484
8485 // hw_palette = &RAMpal;
8486 // update_hw_pal = true;
8487
8488 for(int32_t i=0; i<240; ++i)
8489 {
8490 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8491 }
8492
8493 /*
8494 byte palrstart= 10*63/255, palrend=166*63/255,
8495 palgstart= 36*63/255, palgend=202*63/255,
8496 palbstart=106*63/255, palbend=240*63/255,
8497 paldivs=32;
8498 for(int32_t i=0; i<paldivs; i++)
8499 {
8500 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8501 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8502 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8503 }
8504 */
8505 BITMAP *panorama = create_bitmap_ex(8,256,224);
8506 int32_t ts_height, ts_start;
8507
8508 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8509 {
8510 clear_to_color(panorama,0);
8511 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8512 ts_height=224-passive_subscreen_height;
8513 ts_start=28;
8514 }
8515 else
8516 {
8517 blit(framebuf,panorama,0,0,0,0,256,224);
8518 ts_height=224;
8519 ts_start=0;
8520 }
8521
8522 // gray scale the current frame
8523 for(int32_t y=0; y<ts_height; y++)
8524 {
8525 for(int32_t x=0; x<256; x++)
8526 {
8527 int32_t c = panorama->line[y+ts_start][x];
8528 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8529 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8530 }
8531 }
8532
8533 destroy_bitmap(panorama);
8534
8535 // display everything
8536 vsync();
8537 hw_palette = &RAMpal2;
8538 update_hw_pal = true;
8539
8540 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8541
8542 // sys_pal = pal;
8543 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8544 }
8545
8546 static uint32_t entered_sys_pal = 0;
8547 void enter_sys_pal()
8548 {
8549 if(is_sys_pal)
8550 {
8551 if(entered_sys_pal)
8552 ++entered_sys_pal;
8553 return;
8554 }
8555 system_pal();
8556 ++entered_sys_pal;
8557 }
8558 void exit_sys_pal()
8559 {
8560 if(entered_sys_pal)
8561 {
8562 if(!--entered_sys_pal)
8563 {
8564 game_pal();
8565 }
8566 }
8567 }
8568
8569 void switch_out_callback()
8570 {
8571 if (pause_in_background)
8572 {
8573 callback_switchin = 3;
8574 return;
8575 }
8576
8577 #ifdef _WIN32
8578 if(midi_patch_fix==0 || currmidi==-1)
8579 return;
8580
8581
8582 paused_midi_pos = midi_pos;
8583 zc_stop_midi();
8584 midi_paused=true;
8585 midi_suspended = midissuspHALTED;
8586 #endif
8587 }
8588
8589 void switch_in_callback()
8590 {
8591 zc_update_builtin_font();
8592
8593 if(pause_in_background)
8594 {
8595 return;
8596 }
8597
8598 #ifdef _WIN32
8599 if(midi_patch_fix==0 || currmidi==-1)
8600 return;
8601
8602 else
8603 {
8604 callback_switchin = 1;
8605 midi_suspended = midissuspRESUME;
8606 }
8607 #endif
8608 }
8609
8610 55 void game_pal()
8611 {
8612 55 is_sys_pal = false;
8613 55 entered_sys_pal = 0;
8614 55 clear_to_color(screen,BLACK);
8615 55 hw_palette = &RAMpal;
8616 55 update_hw_pal = true;
8617 55 }
8618
8619 static char bar_str[] = "";
8620
8621 1 void music_pause()
8622 {
8623 //al_pause_duh(tmplayer);
8624 1 zcmusic_pause(zcmusic, ZCM_PAUSE);
8625 1 zc_midi_pause();
8626 1 midi_paused=true;
8627 1 }
8628
8629 void music_resume()
8630 {
8631 //al_resume_duh(tmplayer);
8632 zcmusic_pause(zcmusic, ZCM_RESUME);
8633 zc_midi_resume();
8634 midi_paused=false;
8635 }
8636
8637 613 void music_stop()
8638 {
8639 //al_stop_duh(tmplayer);
8640 //unload_duh(tmusic);
8641 //tmusic=NULL;
8642 //tmplayer=NULL;
8643 613 zcmusic_stop(zcmusic);
8644 613 zcmusic_unload_file(zcmusic);
8645 613 zc_stop_midi();
8646 613 midi_paused=false;
8647 613 currmidi=-1;
8648 613 }
8649
8650 void System()
8651 {
8652 mouse_down=gui_mouse_b();
8653 music_pause();
8654 pause_all_sfx();
8655 MenuOpen = true;
8656 system_pal();
8657 // FONT *oldfont=font;
8658 // font=tfont;
8659
8660 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8661 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8662
8663 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8664 #if DEVLEVEL > 1
8665 dev_menu[4].flags = Playing ? 0 : D_DISABLED;
8666 #endif
8667 game_menu[3].flags =
8668 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8669 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8670 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8671 clear_keybuf();
8672 show_mouse(screen);
8673
8674 DIALOG_PLAYER *p;
8675
8676 clear_bitmap(menu_bmp);
8677 oldscreen = screen;
8678 screen = menu_bmp;
8679
8680 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8681 {
8682 p = init_dialog(system_dlg2,-1);
8683 }
8684 else
8685 {
8686 p = init_dialog(system_dlg,-1);
8687 }
8688
8689 // drop the menu on startup if menu button pressed
8690 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8691 simulate_keypress(KEY_G << 8);
8692
8693 do
8694 {
8695 rest(17);
8696
8697 if(mouse_down && !gui_mouse_b())
8698 mouse_down=0;
8699
8700 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8701 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8702 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8703
8704 settings_menu[0].flags = replay_is_replaying() ? D_DISABLED : 0;
8705 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8706 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8707 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8708 settings_menu[8].flags = NESquit?D_SELECTED:0;
8709 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8710 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8711 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8712 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8713 settings_menu[13].flags = volkeys?D_SELECTED:0;
8714 //Epilepsy Prevention
8715 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8716
8717 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8718 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8719 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8720
8721 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8722 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8723
8724 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8725 cheat_menu[0].flags = 0;
8726 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8727 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8728 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8729 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8730 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8731 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8732 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8733 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8734 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8735
8736 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8737 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8738 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8739 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8740 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8741 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8742 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8743 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8744 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8745 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8746 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8747 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8748 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8749 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8750 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8751
8752 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8753 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8754
8755 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8756 (char *)"Disable recording new saves" :
8757 (char *)"Enable recording new saves";
8758 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8759 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8760 (char *)"Stop recording" :
8761 (char *)"Stop replaying";
8762 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8763
8764 reset_snapshot_format_menu();
8765 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8766
8767 if(debug_enabled)
8768 {
8769 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8770 }
8771
8772 if(gui_mouse_b() && !mouse_down)
8773 break;
8774
8775 // press menu to drop the menu
8776 if(rMbtn())
8777 simulate_keypress(KEY_G << 8);
8778
8779 {
8780 if(input_idle(true) > after_time())
8781 // run Screeen Saver
8782 {
8783 // Screen saver enabled for now.
8784 clear_keybuf();
8785 scare_mouse();
8786 Matrix(ss_speed, ss_density, 0);
8787 system_pal();
8788 unscare_mouse();
8789 broadcast_dialog_message(MSG_DRAW, 0);
8790 }
8791 }
8792 update_hw_screen();
8793 }
8794 while(update_dialog(p));
8795
8796 screen = oldscreen;
8797
8798 // font=oldfont;
8799 mouse_down=gui_mouse_b();
8800 shutdown_dialog(p);
8801 show_mouse(NULL);
8802 MenuOpen = false;
8803 if(Quit)
8804 {
8805 kill_sfx();
8806 music_stop();
8807 update_hw_screen();
8808 }
8809 else
8810 {
8811 game_pal();
8812 music_resume();
8813 resume_all_sfx();
8814
8815 if(rc)
8816 ringcolor(false);
8817 }
8818
8819 eat_buttons();
8820
8821 rc=false;
8822 clear_keybuf();
8823 // text_mode(0);
8824 }
8825
8826 11 void fix_dialogs()
8827 {
8828 11 jwin_center_dialog(about_dlg);
8829 11 jwin_center_dialog(gamepad_dlg);
8830 11 jwin_center_dialog(credits_dlg);
8831 11 jwin_center_dialog(gamemode_dlg);
8832 11 jwin_center_dialog(getnum_dlg);
8833 11 jwin_center_dialog(goto_dlg);
8834 11 jwin_center_dialog(keyboard_control_dlg);
8835 11 jwin_center_dialog(midi_dlg);
8836 11 jwin_center_dialog(quest_dlg);
8837 11 jwin_center_dialog(scrsaver_dlg);
8838 11 jwin_center_dialog(sound_dlg);
8839 11 jwin_center_dialog(triforce_dlg);
8840
8841 // digi_dp[1] += scrx;
8842 // digi_dp[2] += scry;
8843 // midi_dp[1] += scrx;
8844 // midi_dp[2] += scry;
8845 // pan_dp[1] += scrx;
8846 // pan_dp[2] += scry;
8847 // emus_dp[1] += scrx;
8848 // emus_dp[2] += scry;
8849 // buf_dp[1] += scrx;
8850 // buf_dp[2] += scry;
8851 // sfx_dp[1] += scrx;
8852 // sfx_dp[2] += scry;
8853 11 }
8854
8855 /*****************************/
8856 /**** Custom Sound System ****/
8857 /*****************************/
8858
8859 229 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8860 {
8861
4/4
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 120 times.
229 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8862 }
8863
8864 // Run an NSF, or a MIDI if the NSF is missing somehow.
8865 18 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8866 {
8867 18 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8868
8869 // Found it
8870
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(newzcmusic!=NULL)
8871 {
8872 18 zcmusic_stop(zcmusic);
8873 18 zcmusic_unload_file(zcmusic);
8874 18 zc_stop_midi();
8875
8876 18 zcmusic=newzcmusic;
8877 18 zcmusic_play(zcmusic, emusic_volume);
8878
8879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(track>0)
8880 18 zcmusic_change_track(zcmusic,track);
8881
8882 18 return true;
8883 }
8884
8885 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8886 else if(midi>-1000)
8887 jukebox(midi);
8888
8889 return false;
8890 18 }
8891
8892 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8893 {
8894 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8895 // Found it
8896 if(newzcmusic!=NULL)
8897 {
8898 zcmusic_stop(zcmusic);
8899 zcmusic_unload_file(zcmusic);
8900 zc_stop_midi();
8901
8902 zcmusic=newzcmusic;
8903 zcmusic_play(zcmusic, emusic_volume);
8904
8905 if(track>0)
8906 zcmusic_change_track(zcmusic,track);
8907
8908 return true;
8909 }
8910
8911 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8912 else if(midi>-1000)
8913 jukebox(midi);
8914
8915 return false;
8916 }
8917
8918 int32_t get_zcmusicpos()
8919 {
8920 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8921 return debugtracething;
8922 return 0;
8923 }
8924
8925 void set_zcmusicpos(int32_t position)
8926 {
8927 zcmusic_set_curpos(zcmusic, position);
8928 }
8929
8930 void set_zcmusicspeed(int32_t speed)
8931 {
8932 int32_t newspeed = vbound(speed, 0, 10000);
8933 zcmusic_set_speed(zcmusic, newspeed);
8934 }
8935
8936 109 void jukebox(int32_t index,int32_t loop)
8937 {
8938 109 music_stop();
8939
8940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(index<0) index=MAXMIDIS-1;
8941
8942
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(index>=MAXMIDIS) index=0;
8943
8944 109 music_stop();
8945
8946 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8947 // stuck notes when a song stops. This fixes it.
8948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(strcmp(midi_driver->name, "DIGMID")==0)
8949 zc_set_volume(0, 0);
8950
8951 109 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8952 109 zc_play_midi((MIDI*)tunes[index].data,loop);
8953
8954
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 11 times.
109 if(tunes[index].start>0)
8955 11 zc_midi_seek(tunes[index].start);
8956
8957 109 midi_loop_start = tunes[index].loop_start;
8958 109 midi_loop_end = tunes[index].loop_end;
8959
8960 109 currmidi=index;
8961 109 master_volume(digi_volume,midi_volume);
8962 109 midi_paused=false;
8963 109 }
8964
8965 894 void jukebox(int32_t index)
8966 {
8967
1/2
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
894 if(index<0) index=MAXMIDIS-1;
8968
8969
1/2
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
894 if(index>=MAXMIDIS) index=0;
8970
8971 // do nothing if it's already playing
8972
3/4
✓ Branch 0 taken 785 times.
✓ Branch 1 taken 109 times.
✓ Branch 2 taken 785 times.
✗ Branch 3 not taken.
894 if(index==currmidi && midi_pos>=0)
8973 {
8974 785 midi_paused=false;
8975 785 return;
8976 }
8977
8978 109 jukebox(index,tunes[index].loop);
8979 894 }
8980
8981 1353 void play_DmapMusic()
8982 {
8983 static char tfile[2048];
8984 static int32_t ttrack=0;
8985 1353 bool domidi=false;
8986
8987
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 882 times.
1353 if(DMaps[currdmap].tmusic[0]!=0)
8988 {
8989
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
856 if(zcmusic==NULL ||
8990
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8991
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8992 {
8993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(zcmusic != NULL)
8994 {
8995 zcmusic_stop(zcmusic);
8996 zcmusic_unload_file(zcmusic);
8997 zcmusic = NULL;
8998 }
8999
9000 86 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
9001
9002
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(zcmusic!=NULL)
9003 {
9004 86 zc_stop_midi();
9005 86 strcpy(tfile,DMaps[currdmap].tmusic);
9006 86 zcmusic_play(zcmusic, emusic_volume);
9007 86 int32_t temptracks=0;
9008 86 temptracks=zcmusic_get_tracks(zcmusic);
9009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
9010 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
9011 86 zcmusic_change_track(zcmusic,ttrack);
9012 86 }
9013 else
9014 {
9015 tfile[0] = 0;
9016 domidi=true;
9017 }
9018 86 }
9019 471 }
9020 else
9021 {
9022 882 domidi=true;
9023 }
9024
9025
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 882 times.
1353 if(domidi)
9026 {
9027 882 int32_t m=DMaps[currdmap].midi;
9028
9029
3/4
✓ Branch 0 taken 793 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
882 switch(m)
9030 {
9031 case 1:
9032 80 jukebox(ZC_MIDI_OVERWORLD);
9033 80 break;
9034
9035 case 2:
9036 9 jukebox(ZC_MIDI_DUNGEON);
9037 9 break;
9038
9039 case 3:
9040 jukebox(ZC_MIDI_LEVEL9);
9041 break;
9042
9043 default:
9044
3/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 786 times.
793 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9045 786 jukebox(m+MIDIOFFSET_DMAP);
9046 else
9047 7 music_stop();
9048 793 }
9049 882 }
9050 1353 }
9051
9052 1353 void playLevelMusic()
9053 {
9054 1353 int32_t m=tmpscr->screen_midi;
9055
9056
1/6
✓ Branch 0 taken 1353 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1353 switch(m)
9057 {
9058 case -2:
9059 music_stop();
9060 break;
9061
9062 case -1:
9063 1353 play_DmapMusic();
9064 1353 break;
9065
9066 case 1:
9067 jukebox(ZC_MIDI_OVERWORLD);
9068 break;
9069
9070 case 2:
9071 jukebox(ZC_MIDI_DUNGEON);
9072 break;
9073
9074 case 3:
9075 jukebox(ZC_MIDI_LEVEL9);
9076 break;
9077
9078 default:
9079 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9080 jukebox(m+MIDIOFFSET_MAPSCR);
9081 else
9082 music_stop();
9083 }
9084 1353 }
9085
9086 120 void master_volume(int32_t dv,int32_t mv)
9087 {
9088
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 120 times.
✗ Branch 7 not taken.
120 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9089
9090
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
120 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9091
9092
5/6
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107 times.
✓ Branch 5 taken 13 times.
120 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9093 120 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9094 120 }
9095
9096 /*****************/
9097 /***** SFX *****/
9098 /*****************/
9099
9100 // array of voices, one for each sfx sample in the data file
9101 // 0+ = voice #
9102 // -1 = voice not allocated
9103 11 void Z_init_sound()
9104 {
9105
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<WAV_COUNT; i++)
9106 2816 sfx_voice[i]=-1;
9107
9108
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 11 times.
88 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9109 77 tunes[i].data = (MIDI*)mididata[i].dat;
9110
9111
2/2
✓ Branch 0 taken 2772 times.
✓ Branch 1 taken 11 times.
2783 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9112 2772 tunes[ZC_MIDI_COUNT+j].data=NULL;
9113
9114 11 master_volume(digi_volume,midi_volume);
9115 11 }
9116
9117 // returns number of voices currently allocated
9118 int32_t sfx_count()
9119 {
9120 int32_t c=0;
9121
9122 for(int32_t i=0; i<WAV_COUNT; i++)
9123 if(sfx_voice[i]!=-1)
9124 ++c;
9125
9126 return c;
9127 }
9128
9129 // clean up finished samples
9130 940072 void sfx_cleanup()
9131 {
9132
2/2
✓ Branch 0 taken 240658432 times.
✓ Branch 1 taken 940072 times.
241598504 for(int32_t i=0; i<WAV_COUNT; i++)
9133
4/4
✓ Branch 0 taken 3314029 times.
✓ Branch 1 taken 237344403 times.
✓ Branch 2 taken 3307639 times.
✓ Branch 3 taken 6390 times.
240664822 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9134 {
9135 6390 deallocate_voice(sfx_voice[i]);
9136 6390 sfx_voice[i]=-1;
9137 6390 }
9138 940072 }
9139
9140 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9141 // if a voice is already allocated (and/or playing), then it just returns true
9142 // Returns true: voice is allocated
9143 // false: unsuccessful
9144 121151 bool sfx_init(int32_t index)
9145 {
9146 // check index
9147
3/4
✓ Branch 0 taken 113472 times.
✓ Branch 1 taken 7679 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113472 times.
121151 if(index<=0 || index>=WAV_COUNT)
9148 7679 return false;
9149
9150
2/2
✓ Branch 0 taken 104616 times.
✓ Branch 1 taken 8856 times.
113472 if(sfx_voice[index]==-1)
9151 {
9152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8856 times.
8856 if(sfxdat)
9153 {
9154 if(index<Z35)
9155 {
9156 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9157 }
9158 else
9159 {
9160 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9161 }
9162 }
9163 else
9164 {
9165 8856 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9166 }
9167
9168 8856 voice_set_volume(sfx_voice[index], sfx_volume);
9169 8856 }
9170
9171 113472 return sfx_voice[index] != -1;
9172 121151 }
9173
9174 // plays an sfx sample
9175 92409 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9176 {
9177
2/2
✓ Branch 0 taken 88620 times.
✓ Branch 1 taken 3789 times.
92409 if(!sfx_init(index))
9178 3789 return;
9179
9180 88620 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9181 88620 voice_set_pan(sfx_voice[index],pan);
9182
9183 88620 int32_t pos = voice_get_position(sfx_voice[index]);
9184
9185
2/2
✓ Branch 0 taken 42579 times.
✓ Branch 1 taken 46041 times.
88620 if(restart) voice_set_position(sfx_voice[index],0);
9186
9187
2/2
✓ Branch 0 taken 47171 times.
✓ Branch 1 taken 41449 times.
88620 if(pos<=0)
9188 47171 voice_start(sfx_voice[index]);
9189 92409 }
9190
9191 // true if sfx is allocated
9192 2 bool sfx_allocated(int32_t index)
9193 {
9194
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9195 }
9196
9197 // start it (in loop mode) if it's not already playing,
9198 // otherwise adjust it to play in loop mode -DD
9199 28742 void cont_sfx(int32_t index)
9200 {
9201
2/2
✓ Branch 0 taken 3890 times.
✓ Branch 1 taken 24852 times.
28742 if(!sfx_init(index))
9202 {
9203 3890 return;
9204 }
9205
9206
2/2
✓ Branch 0 taken 1429 times.
✓ Branch 1 taken 23423 times.
24852 if(voice_get_position(sfx_voice[index])<=0)
9207 {
9208 1429 voice_set_position(sfx_voice[index],0);
9209 1429 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9210 1429 voice_start(sfx_voice[index]);
9211 1429 }
9212 else
9213 {
9214 23423 adjust_sfx(index, 128, true);
9215 }
9216 28742 }
9217
9218 // adjust parameters while playing
9219 23971 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9220 {
9221
5/6
✓ Branch 0 taken 23652 times.
✓ Branch 1 taken 319 times.
✓ Branch 2 taken 23652 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23459 times.
✓ Branch 5 taken 193 times.
23971 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9222 512 return;
9223
9224 23459 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9225 23459 voice_set_pan(sfx_voice[index],pan);
9226 23971 }
9227
9228 // pauses a voice
9229 124 void pause_sfx(int32_t index)
9230 {
9231
4/6
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 120 times.
124 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9232 4 voice_stop(sfx_voice[index]);
9233 124 }
9234
9235 // resumes a voice
9236 62 void resume_sfx(int32_t index)
9237 {
9238
3/6
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
62 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9239 voice_start(sfx_voice[index]);
9240 62 }
9241
9242 // pauses all active voices
9243 2 void pause_all_sfx()
9244 {
9245
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
514 for(int32_t i=0; i<WAV_COUNT; i++)
9246
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2 times.
514 if(sfx_voice[i]!=-1)
9247 2 voice_stop(sfx_voice[i]);
9248 2 }
9249
9250 // resumes all paused voices
9251 1 void resume_all_sfx()
9252 {
9253
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<WAV_COUNT; i++)
9254
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(sfx_voice[i]!=-1)
9255 voice_start(sfx_voice[i]);
9256 1 }
9257
9258 // stops an sfx and deallocates the voice
9259 731208 void stop_sfx(int32_t index)
9260 {
9261
3/4
✓ Branch 0 taken 728715 times.
✓ Branch 1 taken 2493 times.
✓ Branch 2 taken 728715 times.
✗ Branch 3 not taken.
731208 if(index<=0 || index>=WAV_COUNT)
9262 2493 return;
9263
9264
2/2
✓ Branch 0 taken 1953 times.
✓ Branch 1 taken 726762 times.
728715 if(sfx_voice[index]!=-1)
9265 {
9266 1953 deallocate_voice(sfx_voice[index]);
9267 1953 sfx_voice[index]=-1;
9268 1953 }
9269 731208 }
9270
9271 // Stops SFX played by Hero's item of the given family
9272 4244 void stop_item_sfx(int32_t family)
9273 {
9274 4244 int32_t id=current_item_id(family);
9275
9276
2/2
✓ Branch 0 taken 4172 times.
✓ Branch 1 taken 72 times.
4244 if(id<0)
9277 4172 return;
9278
9279 72 stop_sfx(itemsbuf[id].usesound);
9280 4244 }
9281
9282 228 void kill_sfx()
9283 {
9284
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 228 times.
58596 for(int32_t i=0; i<WAV_COUNT; i++)
9285
2/2
✓ Branch 0 taken 57871 times.
✓ Branch 1 taken 497 times.
58865 if(sfx_voice[i]!=-1)
9286 {
9287 497 deallocate_voice(sfx_voice[i]);
9288 497 sfx_voice[i]=-1;
9289 497 }
9290 228 }
9291
9292 83119 int32_t pan(int32_t x)
9293 {
9294
1/4
✓ Branch 0 taken 83119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
83119 switch(pan_style)
9295 {
9296 case 0:
9297 return 128;
9298
9299 case 1:
9300 83119 return vbound((x>>1)+68,0,255);
9301
9302 case 2:
9303 return vbound(((x*3)>>2)+36,0,255);
9304 }
9305
9306 return vbound(x,0,255);
9307 83119 }
9308
9309 /*******************************/
9310 /******* Input Handlers ********/
9311 /*******************************/
9312
9313 1519858 bool joybtn(int32_t b)
9314 {
9315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1519858 times.
1519858 if(b == 0)
9316 return false;
9317
9318 1519858 return joy[joystick_index].button[b-1].b !=0;
9319 1519858 }
9320
9321 const char* joybtn_name(int32_t b)
9322 {
9323 if(b == 0)
9324 return "";
9325
9326 return joy[joystick_index].button[b-1].name;
9327 }
9328
9329 int32_t next_press_key()
9330 {
9331 return readkey()>>8;
9332 }
9333
9334 int32_t next_press_btn()
9335 {
9336 clear_keybuf();
9337 /*bool b[joy[joystick_index].num_buttons+1];
9338
9339 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9340 b[i]=joybtn(i);*/
9341
9342 //first, we need to wait until they're pressing no buttons
9343 for(;;)
9344 {
9345 if(keypressed())
9346 {
9347 switch(readkey()>>8)
9348 {
9349 case KEY_ESC:
9350 return -1;
9351
9352 case KEY_SPACE:
9353 return 0;
9354 }
9355 }
9356
9357 poll_joystick();
9358 bool done = true;
9359
9360 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9361 {
9362 if(joybtn(i)) done = false;
9363 }
9364
9365 if(done) break;
9366 rest(1);
9367 }
9368
9369 //now, we need to wait for them to press any button
9370 for(;;)
9371 {
9372 if(keypressed())
9373 {
9374 switch(readkey()>>8)
9375 {
9376 case KEY_ESC:
9377 return -1;
9378
9379 case KEY_SPACE:
9380 return 0;
9381 }
9382 }
9383
9384 poll_joystick();
9385
9386 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9387 {
9388 if(joybtn(i)) return i;
9389 }
9390 rest(1);
9391 }
9392 }
9393
9394 static bool rButton(bool(proc)(),bool &flag)
9395 {
9396 if(!proc())
9397 {
9398 flag=false;
9399 }
9400 else if(!flag)
9401 {
9402 flag=true;
9403 return true;
9404 }
9405
9406 return false;
9407 }
9408
9409 18406481 static bool rButton(bool &btn, bool &flag)
9410 {
9411
2/2
✓ Branch 0 taken 725076 times.
✓ Branch 1 taken 17681405 times.
18406481 if(!btn)
9412 {
9413 17681405 flag=false;
9414 17681405 }
9415
2/2
✓ Branch 0 taken 36533 times.
✓ Branch 1 taken 688543 times.
725076 else if(!flag)
9416 {
9417 36533 flag=true;
9418 36533 return true;
9419 }
9420
9421 18369948 return false;
9422 18406481 }
9423 619 static bool rButtonPeek(bool btn, bool flag)
9424 {
9425
2/2
✓ Branch 0 taken 583 times.
✓ Branch 1 taken 36 times.
619 if(!btn)
9426 {
9427 583 return false;
9428 }
9429
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
36 else if(!flag)
9430 {
9431 9 return true;
9432 }
9433
9434 27 return false;
9435 619 }
9436
9437 // Updated only by keyboard/gamepad.
9438 // If in replay mode, this is set directly by the replay system.
9439 // This should never be read from directly - use control_state instead.
9440 bool raw_control_state[ZC_CONTROL_STATES]=
9441 {
9442 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9443 };
9444
9445 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9446 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9447 // lasts until the next call to load_control_state.
9448 bool control_state[ZC_CONTROL_STATES]=
9449 {
9450 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9451 };
9452
9453 bool disable_control[ZC_CONTROL_STATES]=
9454 {
9455 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9456 };
9457
9458 bool drunk_toggle_state[11]=
9459 {
9460 false, false, false, false, false, false, false, false, false, false, false
9461 };
9462
9463 bool disabledKeys[127]=
9464 {
9465 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9466 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9467 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9468 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9469 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9470 false,false,false,false,false,false,false
9471 };
9472
9473 bool KeyInput[127]=
9474 {
9475 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9476 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9477 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9478 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9479 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9480 false,false,false,false,false,false,false
9481 };
9482
9483 bool KeyPress[127]=
9484 {
9485 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9486 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9487 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9488 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9489 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9490 false,false,false,false,false,false,false
9491 };
9492
9493 bool key_current_frame[127];
9494 bool key_previous_frame[127];
9495
9496 static bool key_system[127];
9497 static bool key_system_previous[127];
9498 static bool key_system_press[127];
9499
9500 bool button_press[ZC_CONTROL_STATES] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
9501 bool button_hold[ZC_CONTROL_STATES] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
9502
9503 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9504 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9505 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9506 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9507 #define STICK_PRECISION 56 //define your own sensitivity
9508
9509 738187 void load_control_state()
9510 {
9511
1/2
✓ Branch 0 taken 738187 times.
✗ Branch 1 not taken.
738187 if (!replay_is_replaying())
9512 {
9513 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9514 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9515 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9516 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9517 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9518 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9519 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9520 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9521 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9522 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9523 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9524 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9525 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9526 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9527
9528 if(num_joysticks != 0)
9529 {
9530 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9531 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9532 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9533 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9534 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9535 }
9536 else
9537 {
9538 raw_control_state[14] = false;
9539 raw_control_state[15] = false;
9540 raw_control_state[16] = false;
9541 raw_control_state[17] = false;
9542 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9543 }
9544 }
9545
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 738184 times.
738187 if (replay_is_active())
9546 {
9547
2/2
✓ Branch 0 taken 512475 times.
✓ Branch 1 taken 225709 times.
738184 if (replay_get_version() < 3)
9548 512475 replay_poll();
9549
3/4
✓ Branch 0 taken 225709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9443 times.
✓ Branch 3 taken 216266 times.
225709 else if (replay_is_replaying() && replay_get_version() < 6)
9550 216266 replay_peek_input();
9551 738184 }
9552
9553 // Some test replay files were made before a serious input bug was fixed, so instead
9554 // of re-doing them or tossing them out, just check for that zplay version.
9555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 738181 times.
738187 bool botched_input = replay_is_replaying() && replay_get_version() == 1;
9556
2/2
✓ Branch 0 taken 738181 times.
✓ Branch 1 taken 13287258 times.
14025439 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9557 {
9558 13287258 control_state[i] = raw_control_state[i];
9559
4/4
✓ Branch 0 taken 11093058 times.
✓ Branch 1 taken 2194200 times.
✓ Branch 2 taken 583282 times.
✓ Branch 3 taken 10509776 times.
13287258 if(!botched_input && !control_state[i])
9560 10509776 down_control_states[i] = false;
9561 13287258 }
9562
9563 738181 button_press[0]=rButton(control_state[0],button_hold[0]);
9564 738181 button_press[1]=rButton(control_state[1],button_hold[1]);
9565 738181 button_press[2]=rButton(control_state[2],button_hold[2]);
9566 738181 button_press[3]=rButton(control_state[3],button_hold[3]);
9567 738181 button_press[4]=rButton(control_state[4],button_hold[4]);
9568 738181 button_press[5]=rButton(control_state[5],button_hold[5]);
9569 738181 button_press[6]=rButton(control_state[6],button_hold[6]);
9570 738181 button_press[7]=rButton(control_state[7],button_hold[7]);
9571 738181 button_press[8]=rButton(control_state[8],button_hold[8]);
9572 738181 button_press[9]=rButton(control_state[9],button_hold[9]);
9573 738181 button_press[10]=rButton(control_state[10],button_hold[10]);
9574 738181 button_press[11]=rButton(control_state[11],button_hold[11]);
9575 738181 button_press[12]=rButton(control_state[12],button_hold[12]);
9576 738181 button_press[13]=rButton(control_state[13],button_hold[13]);
9577 738181 button_press[14]=rButton(control_state[14],button_hold[14]);
9578 738181 button_press[15]=rButton(control_state[15],button_hold[15]);
9579 738181 button_press[16]=rButton(control_state[16],button_hold[16]);
9580 738181 button_press[17]=rButton(control_state[17],button_hold[17]);
9581 738181 }
9582
9583 // Returns true if any game key is pressed. This is needed because keypressed()
9584 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9585 3428184 bool zc_key_pressed()
9586 //may also need to use zc_getrawkey
9587 {
9588
7/10
✓ Branch 0 taken 2692319 times.
✓ Branch 1 taken 735865 times.
✓ Branch 2 taken 735865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 735865 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612414 times.
✓ Branch 7 taken 612414 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 148556 times.
3576740 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9589
4/6
✓ Branch 0 taken 612414 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612414 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 436508 times.
✓ Branch 5 taken 436508 times.
612414 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9590
4/6
✓ Branch 0 taken 436508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 436508 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 234356 times.
✓ Branch 5 taken 234356 times.
436508 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9591
4/6
✓ Branch 0 taken 234356 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234356 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 172887 times.
✓ Branch 5 taken 172887 times.
234356 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9592
1/2
✓ Branch 0 taken 172887 times.
✗ Branch 1 not taken.
172887 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9593
3/4
✓ Branch 0 taken 156795 times.
✓ Branch 1 taken 16092 times.
✓ Branch 2 taken 156795 times.
✗ Branch 3 not taken.
172887 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9594
3/4
✓ Branch 0 taken 149613 times.
✓ Branch 1 taken 7182 times.
✓ Branch 2 taken 149613 times.
✗ Branch 3 not taken.
156795 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9595
3/4
✓ Branch 0 taken 149180 times.
✓ Branch 1 taken 433 times.
✓ Branch 2 taken 149180 times.
✗ Branch 3 not taken.
149613 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9596
3/4
✓ Branch 0 taken 148603 times.
✓ Branch 1 taken 577 times.
✓ Branch 2 taken 148603 times.
✗ Branch 3 not taken.
149180 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9597
3/4
✓ Branch 0 taken 148556 times.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 148556 times.
✗ Branch 3 not taken.
148603 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9598
2/4
✓ Branch 0 taken 148556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148556 times.
✗ Branch 3 not taken.
148556 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9599
2/4
✓ Branch 0 taken 148556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148556 times.
✗ Branch 3 not taken.
148556 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9600
2/4
✓ Branch 0 taken 148556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148556 times.
✗ Branch 3 not taken.
148556 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9601
1/2
✓ Branch 0 taken 148556 times.
✗ Branch 1 not taken.
148556 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9602 6191958 return true;
9603
9604 148556 return false;
9605 955876 }
9606
9607 14917847 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9608 {
9609 14917847 bool ret = false, drunkstate = false;
9610 14917847 bool* flag = &down_control_states[btn];
9611
2/7
✓ Branch 0 taken 13960764 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 957083 times.
14917847 switch(btn)
9612 {
9613 case btnF12:
9614 ret = zc_getkey(KEY_F12, ignoreDisable);
9615 eatEntirely = false;
9616 break;
9617 case btnF11:
9618 ret = zc_getkey(KEY_F11, ignoreDisable);
9619 eatEntirely = false;
9620 break;
9621 case btnF5:
9622 ret = zc_getkey(KEY_F5, ignoreDisable);
9623 eatEntirely = false;
9624 break;
9625 case btnQ:
9626 ret = zc_getkey(KEY_Q, ignoreDisable);
9627 eatEntirely = false;
9628 break;
9629 case btnI:
9630 ret = zc_getkey(KEY_I, ignoreDisable);
9631 eatEntirely = false;
9632 break;
9633 case btnM:
9634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 957083 times.
957083 if(FFCore.kb_typing_mode) return false;
9635 957083 ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9636 957083 eatEntirely = false;
9637 957083 break;
9638 default: //control_state[] index
9639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13960764 times.
13960764 if(FFCore.kb_typing_mode) return false;
9640
5/6
✓ Branch 0 taken 13942739 times.
✓ Branch 1 taken 18025 times.
✓ Branch 2 taken 237289 times.
✓ Branch 3 taken 13705450 times.
✓ Branch 4 taken 237289 times.
✗ Branch 5 not taken.
13960764 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9641
2/2
✓ Branch 0 taken 743042 times.
✓ Branch 1 taken 13217722 times.
13960764 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9642
4/4
✓ Branch 0 taken 12380357 times.
✓ Branch 1 taken 1580407 times.
✓ Branch 2 taken 397 times.
✓ Branch 3 taken 1580010 times.
15541171 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9643 13960764 }
9644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14917847 times.
14917847 assert(flag);
9645
2/2
✓ Branch 0 taken 9798005 times.
✓ Branch 1 taken 5119842 times.
14917847 if(press)
9646 {
9647
2/2
✓ Branch 0 taken 619 times.
✓ Branch 1 taken 5119223 times.
5119842 if(peek)
9648 619 ret = rButtonPeek(ret, *flag);
9649 5119223 else ret = rButton(ret, *flag);
9650 5119842 }
9651
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14917847 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14917847 if(eatEntirely && ret) control_state[btn] = false;
9652
3/4
✓ Branch 0 taken 11610645 times.
✓ Branch 1 taken 3307202 times.
✓ Branch 2 taken 11610645 times.
✗ Branch 3 not taken.
14917847 if(drunk && drunkstate) ret = !ret;
9653 14917847 return ret;
9654 14917847 }
9655
9656 8056 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9657 {
9658 8056 byte ret = 0;
9659
2/2
✓ Branch 0 taken 7437 times.
✓ Branch 1 taken 619 times.
8056 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9660
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9661
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9662
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9663
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9664
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9665
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9666
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9667 8056 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9668 }
9669
9670 byte checkIntBtnVal(byte intbtn, byte vals)
9671 {
9672 return intbtn&vals;
9673 }
9674
9675 146363 bool Up()
9676 {
9677 146363 return getInput(btnUp);
9678 }
9679 2426 bool Down()
9680 {
9681 2426 return getInput(btnDown);
9682 }
9683 4170 bool Left()
9684 {
9685 4170 return getInput(btnLeft);
9686 }
9687 4741 bool Right()
9688 {
9689 4741 return getInput(btnRight);
9690 }
9691 8090 bool cAbtn()
9692 {
9693 8090 return getInput(btnA);
9694 }
9695 26096 bool cBbtn()
9696 {
9697 26096 return getInput(btnB);
9698 }
9699 bool cSbtn()
9700 {
9701 return getInput(btnS);
9702 }
9703 296 bool cLbtn()
9704 {
9705 296 return getInput(btnL);
9706 }
9707 296 bool cRbtn()
9708 {
9709 296 return getInput(btnR);
9710 }
9711 bool cPbtn()
9712 {
9713 return getInput(btnP);
9714 }
9715 bool cEx1btn()
9716 {
9717 return getInput(btnEx1);
9718 }
9719 bool cEx2btn()
9720 {
9721 return getInput(btnEx2);
9722 }
9723 bool cEx3btn()
9724 {
9725 return getInput(btnEx3);
9726 }
9727 bool cEx4btn()
9728 {
9729 return getInput(btnEx4);
9730 }
9731 bool AxisUp()
9732 {
9733 return getInput(btnAxisUp);
9734 }
9735 bool AxisDown()
9736 {
9737 return getInput(btnAxisDown);
9738 }
9739 bool AxisLeft()
9740 {
9741 return getInput(btnAxisLeft);
9742 }
9743 bool AxisRight()
9744 {
9745 return getInput(btnAxisRight);
9746 }
9747
9748 bool cMbtn()
9749 {
9750 return getInput(btnM);
9751 }
9752 bool cF12()
9753 {
9754 return getInput(btnF12);
9755 }
9756 bool cF11()
9757 {
9758 return getInput(btnF11);
9759 }
9760 bool cF5()
9761 {
9762 return getInput(btnF5);
9763 }
9764 bool cQ()
9765 {
9766 return getInput(btnQ);
9767 }
9768 bool cI()
9769 {
9770 return getInput(btnI);
9771 }
9772
9773 4381 bool rUp()
9774 {
9775 4381 return getInput(btnUp, true);
9776 }
9777 4371 bool rDown()
9778 {
9779 4371 return getInput(btnDown, true);
9780 }
9781 4370 bool rLeft()
9782 {
9783 4370 return getInput(btnLeft, true);
9784 }
9785 4330 bool rRight()
9786 {
9787 4330 return getInput(btnRight, true);
9788 }
9789 72 bool rAbtn()
9790 {
9791 72 return getInput(btnA, true);
9792 }
9793 4453 bool rBbtn()
9794 {
9795 4453 return getInput(btnB, true);
9796 }
9797 735402 bool rSbtn()
9798 {
9799 735402 return getInput(btnS, true);
9800 }
9801 955876 bool rMbtn()
9802 {
9803 955876 return getInput(btnM, true);
9804 }
9805 4320 bool rLbtn()
9806 {
9807 4320 return getInput(btnL, true);
9808 }
9809 4320 bool rRbtn()
9810 {
9811 4320 return getInput(btnR, true);
9812 }
9813 731084 bool rPbtn()
9814 {
9815 731084 return getInput(btnP, true);
9816 }
9817 bool rEx1btn()
9818 {
9819 return getInput(btnEx1, true);
9820 }
9821 bool rEx2btn()
9822 {
9823 return getInput(btnEx2, true);
9824 }
9825 4320 bool rEx3btn()
9826 {
9827 4320 return getInput(btnEx3, true);
9828 }
9829 4320 bool rEx4btn()
9830 {
9831 4320 return getInput(btnEx4, true);
9832 }
9833 bool rAxisUp()
9834 {
9835 return getInput(btnAxisUp, true);
9836 }
9837 bool rAxisDown()
9838 {
9839 return getInput(btnAxisDown, true);
9840 }
9841 bool rAxisLeft()
9842 {
9843 return getInput(btnAxisLeft, true);
9844 }
9845 bool rAxisRight()
9846 {
9847 return getInput(btnAxisRight, true);
9848 }
9849
9850 bool rF11()
9851 {
9852 return getInput(btnF11, true);
9853 }
9854 bool rQ()
9855 {
9856 return getInput(btnQ, true);
9857 }
9858 bool rI()
9859 {
9860 return getInput(btnI, true);
9861 }
9862
9863 1936178 bool DrunkUp()
9864 {
9865 1936178 return getInput(btnUp, false, true);
9866 }
9867 1790757 bool DrunkDown()
9868 {
9869 1790757 return getInput(btnDown, false, true);
9870 }
9871 1177450 bool DrunkLeft()
9872 {
9873 1177450 return getInput(btnLeft, false, true);
9874 }
9875 1033618 bool DrunkRight()
9876 {
9877 1033618 return getInput(btnRight, false, true);
9878 }
9879 840232 bool DrunkcAbtn()
9880 {
9881 840232 return getInput(btnA, false, true);
9882 }
9883 731857 bool DrunkcBbtn()
9884 {
9885 731857 return getInput(btnB, false, true);
9886 }
9887 730781 bool DrunkcEx1btn()
9888 {
9889 730781 return getInput(btnEx1, false, true);
9890 }
9891 730781 bool DrunkcEx2btn()
9892 {
9893 730781 return getInput(btnEx2, false, true);
9894 }
9895 bool DrunkcSbtn()
9896 {
9897 return getInput(btnS, false, true);
9898 }
9899 bool DrunkcMbtn()
9900 {
9901 return getInput(btnM, false, true);
9902 }
9903 bool DrunkcLbtn()
9904 {
9905 return getInput(btnL, false, true);
9906 }
9907 bool DrunkcRbtn()
9908 {
9909 return getInput(btnR, false, true);
9910 }
9911 bool DrunkcPbtn()
9912 {
9913 return getInput(btnP, false, true);
9914 }
9915
9916 bool DrunkrUp()
9917 {
9918 return getInput(btnUp, true, true);
9919 }
9920 bool DrunkrDown()
9921 {
9922 return getInput(btnDown, true, true);
9923 }
9924 bool DrunkrLeft()
9925 {
9926 return getInput(btnLeft, true, true);
9927 }
9928 bool DrunkrRight()
9929 {
9930 return getInput(btnRight, true, true);
9931 }
9932 587483 bool DrunkrAbtn()
9933 {
9934 587483 return getInput(btnA, true, true);
9935 }
9936 589544 bool DrunkrBbtn()
9937 {
9938 589544 return getInput(btnB, true, true);
9939 }
9940 bool DrunkrEx1btn()
9941 {
9942 return getInput(btnEx1, true, true);
9943 }
9944 bool DrunkrEx2btn()
9945 {
9946 return getInput(btnEx2, true, true);
9947 }
9948 bool DrunkrEx3btn()
9949 {
9950 return getInput(btnEx3, true, true);
9951 }
9952 bool DrunkrEx4btn()
9953 {
9954 return getInput(btnEx4, true, true);
9955 }
9956 bool DrunkrSbtn()
9957 {
9958 return getInput(btnS, true, true);
9959 }
9960 bool DrunkrMbtn()
9961 {
9962 return getInput(btnM, true, true);
9963 }
9964 730788 bool DrunkrLbtn()
9965 {
9966 730788 return getInput(btnL, true, true);
9967 }
9968 730557 bool DrunkrRbtn()
9969 {
9970 730557 return getInput(btnR, true, true);
9971 }
9972 bool DrunkrPbtn()
9973 {
9974 return getInput(btnP, true, true);
9975 }
9976
9977 1207 void eat_buttons()
9978 {
9979 1207 getInput(btnA, true, false, true);
9980 1207 getInput(btnB, true, false, true);
9981 1207 getInput(btnS, true, false, true);
9982 1207 getInput(btnM, true, false, true);
9983 1207 getInput(btnL, true, false, true);
9984 1207 getInput(btnR, true, false, true);
9985 1207 getInput(btnP, true, false, true);
9986 1207 getInput(btnEx1, true, false, true);
9987 1207 getInput(btnEx2, true, false, true);
9988 1207 getInput(btnEx3, true, false, true);
9989 1207 getInput(btnEx4, true, false, true);
9990 1207 }
9991
9992 // Is true for the _first frame_ of a key press.
9993 // But! it is possible that a script manually sets the value of KeyPress,
9994 // in which case it will be restored to the "true" value based on `key_current_frame`
9995 // and `key_previous_frame` on the next frame.
9996 1 bool zc_readkey(int32_t k, bool ignoreDisable)
9997 {
9998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(ignoreDisable) return KeyPress[k];
9999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 switch(k)
10000 {
10001 case KEY_F7:
10002 case KEY_F8:
10003 case KEY_F9:
10004 return KeyPress[k];
10005
10006 default:
10007
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 return KeyPress[k] && !disabledKeys[k];
10008 }
10009 1 }
10010
10011 // Is true for _every frame_ a key is held down.
10012 // But! it is possible that a script manually sets the value of KeyInput,
10013 // in which case it will be restored to the "true" value based on `key_current_frame`
10014 // on the next frame.
10015 bool zc_getkey(int32_t k, bool ignoreDisable)
10016 {
10017 if(ignoreDisable) return KeyInput[k];
10018 switch(k)
10019 {
10020 case KEY_F7:
10021 case KEY_F8:
10022 case KEY_F9:
10023 return KeyInput[k];
10024
10025 default:
10026 return KeyInput[k] && !disabledKeys[k];
10027 }
10028 }
10029
10030 // Reads (and then clears) the current frame key state directly.
10031 // Scripts can also modify `key_current_frame`.
10032 124831 bool zc_readrawkey(int32_t k, bool ignoreDisable)
10033 {
10034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124831 times.
124831 if(zc_getrawkey(k, ignoreDisable))
10035 {
10036 _key[k]=key[k]=key_current_frame[k]=0;
10037 return true;
10038 }
10039 124831 _key[k]=key[k]=key_current_frame[k]=0;
10040 124831 return false;
10041 124831 }
10042
10043 // Reads the current frame key state directly.
10044 // Scripts can also modify `key_current_frame`.
10045 5428235 bool zc_getrawkey(int32_t k, bool ignoreDisable)
10046 {
10047
2/2
✓ Branch 0 taken 4347529 times.
✓ Branch 1 taken 1080706 times.
5428235 if(ignoreDisable) return key_current_frame[k];
10048
2/2
✓ Branch 0 taken 124828 times.
✓ Branch 1 taken 955878 times.
1080706 switch(k)
10049 {
10050 case KEY_F7:
10051 case KEY_F8:
10052 case KEY_F9:
10053 124828 return key_current_frame[k];
10054
10055 default:
10056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 955878 times.
955878 return key_current_frame[k] && !disabledKeys[k];
10057 }
10058 5428235 }
10059
10060 // Only used for a handful of keys, like tilde and Function keys.
10061 // This state is never read within the game.
10062 // It exists so that all keyboard input still functions during replay,
10063 // without inadvertently doing things like toggling throttling if the player
10064 // presses ~
10065 940368 bool zc_get_system_key(int32_t k)
10066 {
10067 940368 return key_system[k];
10068 }
10069
10070 // True for the _first_ frame of a key press.
10071 10514636 bool zc_read_system_key(int32_t k)
10072 {
10073 10514636 return key_system_press[k];
10074 }
10075
10076 121396252 bool is_system_key(int32_t k)
10077 {
10078
2/2
✓ Branch 0 taken 112793368 times.
✓ Branch 1 taken 8602884 times.
121396252 switch (k)
10079 {
10080 case KEY_BACKQUOTE:
10081 case KEY_CLOSEBRACE:
10082 case KEY_END:
10083 case KEY_HOME:
10084 case KEY_OPENBRACE:
10085 case KEY_PGDN:
10086 case KEY_PGUP:
10087 case KEY_TAB:
10088 case KEY_TILDE:
10089 8602884 return true;
10090 }
10091 112793368 return is_Fkey(k);
10092 121396252 }
10093
10094 955876 void update_system_keys()
10095 {
10096 955876 poll_keyboard();
10097
2/2
✓ Branch 0 taken 121396252 times.
✓ Branch 1 taken 955876 times.
122352128 for (int32_t q = 0; q < 127; ++q)
10098 {
10099
2/2
✓ Branch 0 taken 20073396 times.
✓ Branch 1 taken 101322856 times.
121396252 if (!is_system_key(q))
10100 101322856 continue;
10101
10102 20073396 key_system[q] = key[q];
10103
1/2
✓ Branch 0 taken 20073396 times.
✗ Branch 1 not taken.
20073396 key_system_press[q] = key_system[q] && !key_system_previous[q];
10104 20073396 key_system_previous[q] = key_system[q];
10105 20073396 }
10106 955876 }
10107
10108 940368 void update_keys()
10109 {
10110
1/2
✓ Branch 0 taken 940368 times.
✗ Branch 1 not taken.
940368 if (!replay_is_replaying())
10111 poll_keyboard();
10112
10113
2/2
✓ Branch 0 taken 940368 times.
✓ Branch 1 taken 119426736 times.
120367104 for (int32_t q = 0; q < 127; ++q)
10114 {
10115 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10116
1/2
✓ Branch 0 taken 119426736 times.
✗ Branch 1 not taken.
119426736 if (!replay_is_replaying())
10117 key_current_frame[q] = key[q];
10118
10119
2/2
✓ Branch 0 taken 118527205 times.
✓ Branch 1 taken 899531 times.
119426736 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10120
3/4
✓ Branch 0 taken 27677 times.
✓ Branch 1 taken 119399059 times.
✓ Branch 2 taken 27677 times.
✗ Branch 3 not taken.
119426736 if (KeyPress[q] && q == KEY_B) {
10121 int lol = 1;
10122 }
10123 119426736 KeyInput[q] = key_current_frame[q];
10124 119426736 key_previous_frame[q] = key_current_frame[q];
10125 119426736 }
10126 940368 }
10127
10128 bool zc_disablekey(int32_t k, bool val)
10129 {
10130 switch(k)
10131 {
10132 case KEY_F7:
10133 case KEY_F8:
10134 case KEY_F9:
10135 return false;
10136
10137 default:
10138 disabledKeys[k] = val;
10139 return true;
10140 }
10141 }
10142
10143 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10144 {
10145 timer=timer;
10146 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10147 }
10148
10149 // these are here so that copy_dialog won't choke when compiling zelda
10150 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10151 {
10152 return D_O_K;
10153 }
10154
10155 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10156 {
10157 return D_O_K;
10158 }
10159
10160 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10161 {
10162 return D_O_K;
10163 }
10164
10165 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10166 {
10167 return D_O_K;
10168 }
10169
10170 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10171 {
10172 return D_O_K;
10173 }
10174
10175 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10176 {
10177 return D_O_K;
10178 }
10179
10180 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10181 {
10182 return D_O_K;
10183 }
10184
10185 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10186 {
10187 return D_O_K;
10188 }
10189
10190 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10191 {
10192 return D_O_K;
10193 }
10194
10195 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10196 {
10197 return D_O_K;
10198 }
10199
10200 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10201 {
10202 return D_O_K;
10203 }
10204
10205 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10206 {
10207 return D_O_K;
10208 }
10209
10210 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10211 {
10212 return D_O_K;
10213 }
10214
10215 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10216 {
10217 return D_O_K;
10218 }
10219
10220 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10221 {
10222 return D_O_K;
10223 }
10224
10225 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10226 {
10227 return D_O_K;
10228 }
10229
10230 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10231 {
10232 return D_O_K;
10233 }
10234
10235 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10236 {
10237 return D_O_K;
10238 }
10239
10240 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10241 {
10242 return D_O_K;
10243 }
10244
10245 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10246 {
10247 return D_O_K;
10248 }
10249
10250 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10251 {
10252 return D_O_K;
10253 }
10254
10255 /*** end of zc_sys.cc ***/
10256
10257